From 7bfada343146b84363bc17ce8bd3200ce9dd99ce Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 5 Sep 2024 15:52:25 -0700 Subject: [PATCH] wip --- .../.vscode/settings.json | 3 +- .../content/.template.config/template.json | 77 ++-- .../Coalesce.Starter.Vue.Data/AppDbContext.cs | 25 +- .../Auth/AppClaimTypes.cs | 3 + .../Auth/ClaimsPrincipalExtensions.cs | 9 + .../Auth/ClaimsPrincipalFactory.cs | 16 +- .../Auth/SecurityService.cs | 5 +- .../Auth/UserInfo.cs | 1 + .../DatabaseSeeder.cs | 31 ++ .../Coalesce.Starter.Vue.Data/Models/Role.cs | 45 +- .../Models/RoleClaim.cs | 11 - .../Coalesce.Starter.Vue.Data/Models/User.cs | 116 ++++- .../Models/Widget.cs | 3 + .../Api/Generated/RoleController.g.cs | 17 + ...mController.g.cs => WidgetController.g.cs} | 41 +- .../AppInsightsTelemetryEnricher.cs | 4 +- .../Controllers/HomeController.cs | 42 +- .../Models/Generated/RoleClaimDto.g.cs | 94 ---- .../Models/Generated/RoleDto.g.cs | 22 +- .../Models/Generated/UserDto.g.cs | 27 +- .../Models/Generated/UserInfoDto.g.cs | 4 +- .../Models/Generated/WidgetDto.g.cs | 116 +++++ .../Coalesce.Starter.Vue.Web/Program.cs | 126 +++--- .../{Program.Auth.cs => ProgramAuth.cs} | 180 +++++--- .../Coalesce.Starter.Vue.Web/appsettings.json | 23 +- .../Coalesce.Starter.Vue.Web/package.json | 1 + .../src/api-clients.g.ts | 10 +- .../src/components/HelloWorld.vue | 421 +++++++++--------- .../src/components/display/UserAvatar.vue | 11 +- .../src/composables/useTitle.ts | 4 + .../Coalesce.Starter.Vue.Web/src/main.ts | 18 +- .../src/metadata.g.ts | 242 ++++++---- .../Coalesce.Starter.Vue.Web/src/models.g.ts | 81 ++-- .../Coalesce.Starter.Vue.Web/src/router.ts | 39 +- .../src/user-service.ts | 6 + .../src/viewmodels.g.ts | 74 +-- .../src/views/Admin.vue | 96 +++- .../src/views/WidgetEdit.vue | 2 +- .../src/views/errors/Forbidden.vue | 91 ++-- .../src/views/errors/NotFound.vue | 9 +- .../content/Directory.Build.props | 4 +- 41 files changed, 1279 insertions(+), 871 deletions(-) create mode 100644 templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Data/DatabaseSeeder.cs delete mode 100644 templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Data/Models/RoleClaim.cs rename templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/Api/Generated/{RoleClaimController.g.cs => WidgetController.g.cs} (50%) delete mode 100644 templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/Models/Generated/RoleClaimDto.g.cs create mode 100644 templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/Models/Generated/WidgetDto.g.cs rename templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/{Program.Auth.cs => ProgramAuth.cs} (55%) diff --git a/templates/Coalesce.Vue.Template/.vscode/settings.json b/templates/Coalesce.Vue.Template/.vscode/settings.json index 8c5a1a9f5..5440fd3b7 100644 --- a/templates/Coalesce.Vue.Template/.vscode/settings.json +++ b/templates/Coalesce.Vue.Template/.vscode/settings.json @@ -1,3 +1,4 @@ { - "dotnet.defaultSolution": "content\\Coalesce.Starter.Vue.sln" + "dotnet.defaultSolution": "content\\Coalesce.Starter.Vue.sln", + "editor.formatOnSave": true, } \ No newline at end of file diff --git a/templates/Coalesce.Vue.Template/content/.template.config/template.json b/templates/Coalesce.Vue.Template/content/.template.config/template.json index e4bf22c13..d7e424735 100644 --- a/templates/Coalesce.Vue.Template/content/.template.config/template.json +++ b/templates/Coalesce.Vue.Template/content/.template.config/template.json @@ -1,15 +1,15 @@ { "$schema": "http://json.schemastore.org/template", "author": "IntelliTect", - "classifications": [ "Web", "MVC", "Vue" ], + "classifications": ["Web", "MVC", "Vue"], "identity": "IntelliTect.Coalesce.Vue.Template", "name": "IntelliTect Coalesce Web App Vue Template", "shortName": "coalescevue", "tags": { - "language": "C#", - "type":"project" + "language": "C#", + "type": "project" }, - "sourceName": "Coalesce.Starter.Vue", + "sourceName": "Coalesce.Starter.Vue", "preferNameDirectory": true, "symbols": { "KestrelPortGenerated": { @@ -28,7 +28,7 @@ }, "replaces": "5002" }, - + "Identity": { "type": "parameter", "datatype": "bool" @@ -81,8 +81,9 @@ { "condition": "!Identity", "exclude": [ - "**/Program.Auth.cs", + "**/ProgramAuth.cs", "**/Forbidden.vue", + "**/UserAvatar.vue", "**/SignIn.cshtml", "**/SignIn.cshtml.cs", "**/AppClaimTypes.cs", @@ -91,53 +92,36 @@ "**/Permission.cs", "**/User.cs", "**/UserRole.cs", - "**/Role.cs", - "**/RoleClaim.cs" + "**/Role.cs" ] }, { "condition": "!(UserPictures && Identity)", - "exclude": [ - "Coalesce.Starter.Vue.Data/Models/UserPhoto.cs" - ] + "exclude": ["Coalesce.Starter.Vue.Data/Models/UserPhoto.cs"] }, { "condition": "!AuditLogs", - "exclude": [ - "**/AuditOperationContext.cs", - "**/AuditLog.cs" - ] + "exclude": ["**/AuditOperationContext.cs", "**/AuditLog.cs"] }, { "condition": "!TrackingBase", - "exclude": [ - "**/TrackingBase.cs" - ] + "exclude": ["**/TrackingBase.cs"] }, { "condition": "!AppInsights", - "exclude": [ - "**/AppInsightsTelemetryEnricher.cs" - ] + "exclude": ["**/AppInsightsTelemetryEnricher.cs"] }, { "condition": "!GoogleAuth", - "exclude": [ - "**/google-logo.svg" - ] + "exclude": ["**/google-logo.svg"] }, { "condition": "!MicrosoftAuth", - "exclude": [ - "**/microsoft-logo.svg" - ] + "exclude": ["**/microsoft-logo.svg"] }, { "condition": "!ExampleModel", - "exclude": [ - "**/WidgetEdit.vue", - "**/WidgetEdit.spec.ts" - ] + "exclude": ["**/WidgetEdit.vue", "**/WidgetEdit.spec.ts"] } ] } @@ -148,14 +132,14 @@ { "type": "conditional", "configuration": { - "if": [ "//#if" ], - "else": [ "//#else" ], - "elseif": [ "//#elseif" ], - "endif": [ "//#endif" ], - "actionableIf": [ "////#if" ], - "actionableElse": [ "////#else" ], - "actionableElseif": [ "////#elseif" ], - "actions": [ "cStyleUncomment", "cStyleReduceComment" ], + "if": ["//#if"], + "else": ["//#else"], + "elseif": ["//#elseif"], + "endif": ["//#endif"], + "actionableIf": ["////#if"], + "actionableElse": ["////#else"], + "actionableElseif": ["////#elseif"], + "actions": ["cStyleUncomment", "cStyleReduceComment"], "trim": true, "wholeLine": true, "evaluator": "C++" @@ -164,10 +148,15 @@ { "type": "conditional", "configuration": { - "endif": [ "#endif", " +

3. Add Authentication

+ Implement a proper authentication mechanism in + Program.cs and remove the existing dummy authentication. If you want + to use + - - - - + ASP.NET Core Identity , you should start over and include the Identity option when + instantiating the Coalesce project template. Otherwise, + + read more about authentication in ASP.NET Core . +
+
+ This template authenticates all users as a dummy user to facilitate + rapid initial development. Since all Coalesce endpoints require + authentication by default, you would otherwise have to setup a real + authentication scheme before you could begin development. + + + +
+ + + Development Environment Recommended Tooling: + + + + + - - - +

+ Visual Studio is recommended for back-end C# work, but other + IDEs like Rider or VS Code can also be used. +

+ Recommended extensions: + +
+
+ + + - - - + VS Code is recommended for front-end Vue/Typescript work, with + these extensions: + -

- Here are some next steps to get started: -

-
    -
  1. - Create your data model by adding classes to the - Models folder in your data project, and adding DbSet properties - on AppDbContext. -
  2. -
  3. - Create an EF migration by running - dotnet ef migrations add MigrationName - in your .Data project. The pages below will not work until you - do so. -
  4. -
  5. - - Implement a proper authentication mechanism in - Program.cs and remove the existing dummy authentication. Options - include - - Identity - - and - - Windows Authentication - - -
    -
    - This template authenticates all users as a dummy user to - facilitate rapid initial development. Since all Coalesce - endpoints require authentication by default, you would otherwise - have to setup a real authentication scheme before you could - begin development. -
  6. -
  7. - Check out the other pages in the sidebar for - examples and - admin page links! -
  8. -
- -

- Development Environment Recommended Tooling: -

-
- - + + +
- - - Visual Studio is recommended for back-end C# work, but other - IDEs like Rider or VS Code can also be used. Recommended - extensions: - - - - - - - - VS Code is recommended for front-end Vue/Typescript work, with - these extensions: - - - - - -
- - - -
-
- - Recommended browser extensions: - - -
-
+ +
+ + + Recommended browser extensions: + + +
@@ -198,36 +166,31 @@ Quick Links -

Documentation

- + + + + + + + + +

Resources

    @@ -251,12 +214,13 @@ defineProps<{ msg: string | null }>(); - diff --git a/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/components/display/UserAvatar.vue b/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/components/display/UserAvatar.vue index 4d4b72461..d5587ed07 100644 --- a/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/components/display/UserAvatar.vue +++ b/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/components/display/UserAvatar.vue @@ -22,17 +22,14 @@ diff --git a/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/WidgetEdit.vue b/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/WidgetEdit.vue index 76d7dbecf..4d230e6dd 100644 --- a/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/WidgetEdit.vue +++ b/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/WidgetEdit.vue @@ -51,7 +51,7 @@ import { useBindKeyToRouteOnCreate } from "coalesce-vue"; const props = defineProps<{ id?: number }>(); -useTitle(() => item.name); +useTitle(() => (props.id ? item.name || "Loading" : "Create Widget")); const form = useForm(); // The properties on the generated ViewModels are already reactive. diff --git a/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/errors/Forbidden.vue b/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/errors/Forbidden.vue index 44a8a2d0d..b3cf7d4a3 100644 --- a/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/errors/Forbidden.vue +++ b/templates/Coalesce.Vue.Template/content/Coalesce.Starter.Vue.Web/src/views/errors/Forbidden.vue @@ -1,55 +1,46 @@