From 0b15dd50ab2b0adbe8f7421f9b46cd9207a586d1 Mon Sep 17 00:00:00 2001 From: morbalint Date: Sat, 23 Dec 2023 19:59:13 +0100 Subject: [PATCH] set basic layout, error boundary, add QR code for 2FA --- .../Account/Manage/EnableAuthenticator.cshtml | 5 +- .../Manage/EnableAuthenticator.cshtml.cs | 2 +- .../Pages/Account/RegisterConfirmation.cshtml | 1 - Kemkas.Web/Controllers/CharacterController.cs | 10 +- Kemkas.Web/Pages/Shared/_Layout.cshtml | 6 +- .../Character/CharacterPersistenceService.cs | 32 +- Kemkas.Web/ViewModels/CharacterListItemDto.cs | 21 + Kemkas.Web/appsettings.Development.json | 4 - Kemkas.Web/frontend/public/index.html | 7 +- Kemkas.Web/frontend/src/App.css | 13 + Kemkas.Web/frontend/src/App.tsx | 49 +- .../components/CharacterListItem.tsx | 25 + .../src/first-edition/pages/CharacterList.tsx | 37 ++ .../first-edition/pages/CreateCharacter.tsx | 8 +- .../src/first-edition/pages/ErrorBoundary.tsx | 16 + Kemkas.Web/frontend/src/index.css | 5 - Kemkas.Web/nginx.conf | 13 + Kemkas.Web/wwwroot/css/site.css | 4 - Kemkas.Web/wwwroot/js/qr.js | 9 + Kemkas.Web/wwwroot/js/qrcode.js | 614 ++++++++++++++++++ Kemkas.Web/wwwroot/lib/qrcode/.gitignore | 4 + Kemkas.Web/wwwroot/lib/qrcode/LICENSE | 14 + Kemkas.Web/wwwroot/lib/qrcode/README.md | 46 ++ Kemkas.Web/wwwroot/lib/qrcode/bower.json | 18 + Kemkas.Web/wwwroot/lib/qrcode/index-svg.html | 47 ++ Kemkas.Web/wwwroot/lib/qrcode/index.html | 44 ++ Kemkas.Web/wwwroot/lib/qrcode/index.svg | 37 ++ Kemkas.Web/wwwroot/lib/qrcode/jquery.min.js | 2 + Kemkas.Web/wwwroot/lib/qrcode/qrcode.js | 614 ++++++++++++++++++ Kemkas.Web/wwwroot/lib/qrcode/qrcode.min.js | 1 + 30 files changed, 1674 insertions(+), 34 deletions(-) create mode 100644 Kemkas.Web/ViewModels/CharacterListItemDto.cs create mode 100644 Kemkas.Web/frontend/src/first-edition/components/CharacterListItem.tsx create mode 100644 Kemkas.Web/frontend/src/first-edition/pages/CharacterList.tsx create mode 100644 Kemkas.Web/frontend/src/first-edition/pages/ErrorBoundary.tsx create mode 100644 Kemkas.Web/wwwroot/js/qr.js create mode 100644 Kemkas.Web/wwwroot/js/qrcode.js create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/.gitignore create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/LICENSE create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/README.md create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/bower.json create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/index-svg.html create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/index.html create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/index.svg create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/jquery.min.js create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/qrcode.js create mode 100644 Kemkas.Web/wwwroot/lib/qrcode/qrcode.min.js diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml index fefa57f..d73358a 100644 --- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml +++ b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml @@ -22,7 +22,7 @@
  • Scan the QR Code or enter this key @Model.SharedKey into your two factor authenticator app. Spaces and casing do not matter.

    - + @* *@
  • @@ -50,4 +50,7 @@ @section Scripts { + + + } diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs index dd9f0f7..919bb97 100644 --- a/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs +++ b/Kemkas.Web/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs @@ -181,7 +181,7 @@ namespace Kemkas.Web.Areas.Identity.Pages.Account.Manage return string.Format( CultureInfo.InvariantCulture, AuthenticatorUriFormat, - _urlEncoder.Encode("Microsoft.AspNetCore.Identity.UI"), + _urlEncoder.Encode("Kemkas"), _urlEncoder.Encode(email), unformattedKey); } diff --git a/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml b/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml index b15d7c0..04321a5 100644 --- a/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml +++ b/Kemkas.Web/Areas/Identity/Pages/Account/RegisterConfirmation.cshtml @@ -8,5 +8,4 @@

    Please check your email to confirm your account.

    -} diff --git a/Kemkas.Web/Controllers/CharacterController.cs b/Kemkas.Web/Controllers/CharacterController.cs index 40e0c70..14136ec 100644 --- a/Kemkas.Web/Controllers/CharacterController.cs +++ b/Kemkas.Web/Controllers/CharacterController.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations; using Kemkas.Web.Db.Models; using Kemkas.Web.Services.Character; using Kemkas.Web.ViewModels; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Kemkas.Web.Controllers; @@ -16,7 +17,7 @@ public class CharacterController( : ControllerBase { [HttpPost] - public async Task> StoreNewCharacter([FromBody] CharacterDto dto) + public async Task> StoreNewCharacter([FromBody] CharacterDto dto, bool isPublic = true) { if (!ModelState.IsValid) { @@ -52,4 +53,11 @@ public class CharacterController( return dbModelToDtoService.Convert(entity); } + + [HttpGet] + [Authorize] + public async Task> GetAllCharacters() + { + return await persistenceService.GetAllCharactersOfUser(); + } } \ No newline at end of file diff --git a/Kemkas.Web/Pages/Shared/_Layout.cshtml b/Kemkas.Web/Pages/Shared/_Layout.cshtml index de6b25f..eb882dc 100644 --- a/Kemkas.Web/Pages/Shared/_Layout.cshtml +++ b/Kemkas.Web/Pages/Shared/_Layout.cshtml @@ -3,11 +3,11 @@ @inject IWebHostEnvironment Environment @inject ICompositeViewEngine Engine - + - @ViewData["Title"] - Kemkas.Web + @ViewData["Title"] - Kemkas @@ -25,7 +25,7 @@
    +
    +
    + +
    +
    +
    + A Kard és Mágiát Lux Gábor alkotta. A szerzői jogok őt illetik. Ez az oldal egy "rajongói + hozzájárulás", célja a Kard és Mágia népszerűsítése. Ha többet akarsz tudni a Kard és Mágiáról + látogass el a hivatalos honlapjára. A Kard és Mágia az Open + Gaming Licence 1.0a alatt lett kiadva, melynek szövege itt található +
    +
    + ); } diff --git a/Kemkas.Web/frontend/src/first-edition/components/CharacterListItem.tsx b/Kemkas.Web/frontend/src/first-edition/components/CharacterListItem.tsx new file mode 100644 index 0000000..d74cee9 --- /dev/null +++ b/Kemkas.Web/frontend/src/first-edition/components/CharacterListItem.tsx @@ -0,0 +1,25 @@ +import * as React from "react"; +import {Osztaly, OsztalyLabel} from "../domain-models/osztaly"; +import {Faj, FajLabel} from "../domain-models/faj"; + +export interface CharacterListItemDto { + id: string, + name: string, + szint: number, + faj: Faj, + osztaly: Osztaly, +} + +function CharacterListItem(props: { + character: CharacterListItemDto, +}) { + const {character:c} = props + return <> + {c.name} + {c.szint}. szintű + {FajLabel(c.faj)} + {OsztalyLabel(c.osztaly)} + +} + +export default CharacterListItem; \ No newline at end of file diff --git a/Kemkas.Web/frontend/src/first-edition/pages/CharacterList.tsx b/Kemkas.Web/frontend/src/first-edition/pages/CharacterList.tsx new file mode 100644 index 0000000..139797d --- /dev/null +++ b/Kemkas.Web/frontend/src/first-edition/pages/CharacterList.tsx @@ -0,0 +1,37 @@ +import * as React from "react"; +import {useLoaderData} from "react-router-dom"; +import CharacterListItem, {CharacterListItemDto} from "../components/CharacterListItem"; +import {Faro} from "@grafana/faro-web-sdk"; + +function CharacterList(props: {faro?: Faro}) { + const {faro} = props + const characters = useLoaderData() as CharacterListItemDto[]; + + return
    +
    +

    Karakterek

    +
    + + + + + + + + + + + + {characters.map(c => ( + + + + ))} + +
    NévSzintFajOsztály
    +
    +} + +export default CharacterList; \ No newline at end of file diff --git a/Kemkas.Web/frontend/src/first-edition/pages/CreateCharacter.tsx b/Kemkas.Web/frontend/src/first-edition/pages/CreateCharacter.tsx index 7755886..e8e7b54 100644 --- a/Kemkas.Web/frontend/src/first-edition/pages/CreateCharacter.tsx +++ b/Kemkas.Web/frontend/src/first-edition/pages/CreateCharacter.tsx @@ -59,7 +59,7 @@ function CreateCharacterPage(props: { return (
    -

    Karakter létrehozása

    +

    Karakter {initialKarakterInputs ? "szerkesztése*" : "létrehozása"}

    event.preventDefault()}> @@ -179,7 +179,8 @@ function CreateCharacterPage(props: {