Skip to content

Commit

Permalink
Replace dashboard implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
wmeints committed Aug 1, 2024
1 parent 16afd4e commit e2229fb
Show file tree
Hide file tree
Showing 13 changed files with 2,559 additions and 2 deletions.
18 changes: 18 additions & 0 deletions apps/dashboard/PaperBoy.Dashboard/Components/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="stylesheet" href="app.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
</head>

<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@inherits LayoutComponentBase

@Body
4 changes: 4 additions & 0 deletions apps/dashboard/PaperBoy.Dashboard/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@page "/"
@attribute [Authorize]

<h1>Hello world</h1>
6 changes: 6 additions & 0 deletions apps/dashboard/PaperBoy.Dashboard/Components/Routes.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
</Router>
11 changes: 11 additions & 0 deletions apps/dashboard/PaperBoy.Dashboard/Components/_Imports.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using PaperBoy.Dashboard
@using PaperBoy.Dashboard.Components
7 changes: 7 additions & 0 deletions apps/dashboard/PaperBoy.Dashboard/PaperBoy.Dashboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Auth0.AspNetCore.Authentication" Version="1.4.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
</Project>
47 changes: 46 additions & 1 deletion apps/dashboard/PaperBoy.Dashboard/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,51 @@
using Auth0.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using PaperBoy.Dashboard.Components;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddAuth0WebAppAuthentication(options =>
{
options.Domain = builder.Configuration["Auth0:Domain"]!;
options.ClientId = builder.Configuration["Auth0:ClientId"]!;
options.ClientSecret = builder.Configuration["Auth0:ClientSecret"]!;
options.Scope = "openid profile email";
});

builder.Services.AddAntiforgery();

builder.Services.AddRazorComponents().AddInteractiveServerComponents();

var app = builder.Build();

app.MapGet("/", () => "Hello World!");
app.UseStaticFiles();

app.UseRouting();
app.UseAntiforgery();

app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/Account/Login", async (HttpContext HttpContext, string returnUrl = "/") =>
{
var authenticationProperties = new LoginAuthenticationPropertiesBuilder()
.WithRedirectUri(returnUrl)
.Build();

await HttpContext.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties);
});

app.MapGet("/Account/Logout", async (HttpContext HttpContext) =>
{
var authenticationProperties = new LoginAuthenticationPropertiesBuilder()
.WithRedirectUri("/")
.Build();

await HttpContext.SignOutAsync(Auth0Constants.AuthenticationScheme, authenticationProperties);
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
});

app.MapRazorComponents<App>().AddInteractiveServerRenderMode();

app.Run();
3 changes: 3 additions & 0 deletions apps/dashboard/PaperBoy.Dashboard/Stylesheets/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
Loading

0 comments on commit e2229fb

Please sign in to comment.