Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/azure-static-web-apps-lemon-ground-063b78b1e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Azure Static Web Apps CI/CD

on:
push:
branches:
- authentication
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- authentication

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_GROUND_063B78B1E }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "Client" # App source code path
api_location: "Api" # Api source code path - optional
output_location: "wwwroot" # Built app content directory - optional
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_GROUND_063B78B1E }}
action: "close"
19 changes: 0 additions & 19 deletions App.razor

This file was deleted.

52 changes: 52 additions & 0 deletions DungeonMasterDashboard.Server/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using DungeonMasterDashboard.Server.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;

namespace DungeonMasterDashboard.Server.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class AccountController : ControllerBase
{
private readonly UserManager<IdentityUser> userManager;

public AccountController(UserManager<IdentityUser> userManager)
{
this.userManager = userManager;
}

[HttpGet]
public IActionResult Welcome()
{
if (User.Identity == null || !User.Identity.IsAuthenticated)
{
return Ok("You are NOT authenticated");
}

return Ok("You are authenticated");
}

[Authorize]
[HttpGet("Profile")]
public async Task<IActionResult> Profile()
{
var currentUser = await userManager.GetUserAsync(User);
if (currentUser == null)
{
return BadRequest();
}

var userProfile = new UserProfile
{
Id = currentUser.Id,
Name = currentUser.UserName ?? "",
Email = currentUser.Email ?? "",
PhoneNumber = currentUser.PhoneNumber ?? ""
};

return Ok(userProfile);
}
}
}
24 changes: 24 additions & 0 deletions DungeonMasterDashboard.Server/DungeonMasterDashboard.Server.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.1.2" />
</ItemGroup>

<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DungeonMasterDashboard\DungeonMasterDashboard.csproj"
ReferenceOutputAssembly="false" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions DungeonMasterDashboard.Server/Models/UserProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace DungeonMasterDashboard.Server.Models
{
public class UserProfile
{
public string Id { get; set; } = "";
public string Name { get; set; } = "";
public string Email { get; set; } = "";
public string PhoneNumber { get; set; } = "";

}
}
26 changes: 26 additions & 0 deletions DungeonMasterDashboard.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.ResponseCompression;

var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
Args = args,
ContentRootPath = AppContext.BaseDirectory,
WebRootPath = "wwwroot"
});

builder.Services.AddControllers();

builder.WebHost.UseUrls("http://0.0.0.0:8080");

var app = builder.Build();

app.UseHttpsRedirection();

app.UseBlazorFrameworkFiles();
app.UseStaticFiles();

app.UseRouting();

app.MapControllers();
app.MapFallbackToFile("index.html");

app.Run();
24 changes: 24 additions & 0 deletions DungeonMasterDashboard.Server/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5041",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7090;http://localhost:5041",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
8 changes: 8 additions & 0 deletions DungeonMasterDashboard.Server/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
12 changes: 12 additions & 0 deletions DungeonMasterDashboard.Server/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=dm_dashboard;Integrated Security=True;TrustServerCertificate=True"
}
}
13 changes: 13 additions & 0 deletions DungeonMasterDashboard.Server/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "10.0.3",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}
29 changes: 0 additions & 29 deletions DungeonMasterDashboard.csproj

This file was deleted.

3 changes: 0 additions & 3 deletions DungeonMasterDashboard.slnx

This file was deleted.

17 changes: 17 additions & 0 deletions DungeonMasterDashboard/App.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Router AppAssembly="@typeof(App).Assembly" NotFoundPage="typeof(Pages.NotFound)">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
@* <NotAuthorized>
@if (context.User.Identity?.IsAuthenticated != true)
{
<RedirectToLogin />
}
else
{
<p role="alert">You are not authorized to access this resource.</p>
}
</NotAuthorized> *@
</RouteView>
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
</Router>
23 changes: 23 additions & 0 deletions DungeonMasterDashboard/DungeonMasterDashboard.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OverrideHtmlAssetPlaceholders>true</OverrideHtmlAssetPlaceholders>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="10.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.3" PrivateAssets="all" />
</ItemGroup>


<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions DungeonMasterDashboard/DungeonMasterDashboard.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Solution>
<Project Path="../DungeonMasterDashboard.Server/DungeonMasterDashboard.Server.csproj" Id="b9094971-53da-4142-84a7-303a47a244f5" />
<Project Path="DungeonMasterDashboard.csproj" />
</Solution>
22 changes: 22 additions & 0 deletions DungeonMasterDashboard/Layout/LoginDisplay.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@inject NavigationManager Navigation
@* @inject AuthenticationStateProvider authStateProvider *@

@* <AuthorizeView>
<Authorized>
Hello, @context.User.Identity?.Name!
<button class="nav-link btn btn-link" @onclick="BeginLogOut">Log out</button>
</Authorized>
<NotAuthorized>
<a href="auth/login">Log in</a>
<a href="auth/register">Register</a>
</NotAuthorized>
</AuthorizeView> *@

@code{
// public void BeginLogOut()
// {
// var custAuthStateProvider = (CustomAuthenticationStateProvider)authStateProvider;
// custAuthStateProvider.Logout();
// Navigation.NavigateTo("/");
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<main>
<div class="top-row px-4 auth">
<LoginDisplay />
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>

<article class="content px-4">
Expand Down
Loading