Skip to content

Commit

Permalink
Merge branch 'mvc-based-identity'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexZeitler committed Jul 27, 2024
2 parents 34ada40 + c46efe0 commit d505f23
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
root = true

[**/**.{cs,cshtml,js,json,yml}]
[**/**.{cs,cshtml,html,js,json,yml}]
indent_style = space
indent_size = 2
insert_final_newline = true
8 changes: 8 additions & 0 deletions src/AspNetMartenHtmxVsa/ConfigureHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public static IHostBuilder GetHostBuilder(

services.AddDefaultIdentity<AppUser>(options => options.SignIn.RequireConfirmedAccount = false)
.AddEntityFrameworkStores<AppDbContext>();

services.ConfigureApplicationCookie(
options =>
{
options.LoginPath = "/Login/Login";
}
);

services.AddTransient<IClaimsTransformation, OidcLikeClaimsTransformation>();

Expand Down Expand Up @@ -78,6 +85,7 @@ public static IHostBuilder GetHostBuilder(
routeBuilder.MapControllers();
routeBuilder.MapRazorPages();
routeBuilder.MapDefaultControllerRoute();
routeBuilder.MapFallbackToController("GetHome", "GetHome");
}
);
}
Expand Down
5 changes: 1 addition & 4 deletions src/AspNetMartenHtmxVsa/Features/Account/LogOff/LogOff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ ILoggerFactory loggerFactory
}


//
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
[HttpGet("/signout")]
public async Task<IActionResult> LogOff()
{
await _signInManager.SignOutAsync();
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetMartenHtmxVsa/Features/Account/Login/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public IActionResult Login(
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
// [ValidateAntiForgeryToken]
public async Task<IActionResult> Login(
LoginViewModel model,
string returnUrl = null

Check warning on line 67 in src/AspNetMartenHtmxVsa/Features/Account/Login/Login.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
Expand Down
1 change: 1 addition & 0 deletions src/AspNetMartenHtmxVsa/Features/GetHome/GetHome.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@inject UserManager<AppUser> UserManager
@{
ViewData["Title"] = "Home Page";
Layout = "TwoColumnLayout";
}

<div class="text-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@model IEnumerable<Marten.Events.Projections.IReadOnlyProjectionData>

@{
Layout = "_Layout";
Layout = "TwoColumnLayout";
}


Expand Down
4 changes: 2 additions & 2 deletions src/AspNetMartenHtmxVsa/Layouts/TwoColumnLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ To: "-translate-x-full"
src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80">
<span class="hidden lg:flex lg:items-center">
<span aria-hidden="true"
class="ml-4 text-sm font-semibold leading-6 text-gray-900">@appUser.FirstName @appUser.LastName</span>
class="ml-4 text-sm font-semibold leading-6 text-gray-900">@appUser?.FirstName @appUser?.LastName</span>
<svg aria-hidden="true"
class="ml-2 h-5 w-5 text-gray-400"
fill="currentColor"
Expand Down Expand Up @@ -531,7 +531,7 @@ To: "-translate-x-full"
role="menuitem"
tabindex="-1">Your profile</a>
<a class="block px-3 py-1 text-sm leading-6 text-gray-900"
href="#"
href="@Url.ActionLink("LogOff","LogOff")"
id="user-menu-item-1"
role="menuitem"
tabindex="-1">Sign out</a>
Expand Down
69 changes: 0 additions & 69 deletions src/AspNetMartenHtmxVsa/Layouts/_Layout.cshtml

This file was deleted.

40 changes: 0 additions & 40 deletions src/AspNetMartenHtmxVsa/Layouts/_LayoutSettings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,7 @@
@{ Layout = "ThreeColumnFullWidthLayout"; }

@{
// var getPaymentTermsLink = Url.Action("GetPaymentTerms", "GetPaymentTerms");
// var getDeliveryTermsLink = Url.Action("GetDeliveryTerms", "GetDeliveryTerms");
// var setSubscriptionAddressLink = Url.Action("SetSubscriptionAddress", "SetSubscriptionAddress");
// var getUsersLink = Url.Action("GetUsers", "GetUsers");
var items = new List<NavigationItem>();
// {
// new(
// "Zahlungsbedingungen",
// getPaymentTermsLink!,
// null,
// new[] { getPaymentTermsLink! },
// IconSymbol.CreditCard
// ),
// new(
// "Lieferbedingungen",
// getDeliveryTermsLink!,
// null,
// new[] { getDeliveryTermsLink! },
// IconSymbol.GlobeAlt
// ),
// new(
// "Unternehmen",
// "/settings/organization",
// null,
// new[] { "/settings/organization" },
// IconSymbol.BuildingOffice2
// ),
// new(
// "Account",
// setSubscriptionAddressLink!,
// null,
// new[] { setSubscriptionAddressLink! },
// IconSymbol.CurrencyEuro
// ),
// new(
// "Benutzer",
// getUsersLink!,
// null,
// new[] { getUsersLink! },
// IconSymbol.Users
// )
};
}

Expand Down
10 changes: 6 additions & 4 deletions src/AspNetMartenHtmxVsa/Layouts/_LoginPartial.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@inject SignInManager<AppUser> SignInManager
@inject UserManager<AppUser> UserManager

<div class="bg-red-200">Login Partial</div>
<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
{
Expand Down Expand Up @@ -30,14 +31,15 @@
else
{
<li class="nav-item">
<a asp-area="Identity"
asp-page="/Account/Register"
<a asp-action="Register"
asp-controller="Register"
class="nav-link text-dark"
id="register">Register</a>
</li>
<li class="nav-item">
<a asp-area="Identity"
asp-page="/Account/Login"
<a asp-action="Login"
asp-controller="Login"

class="nav-link text-dark"
id="login">Login</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetMartenHtmxVsa/_ViewStart.cshtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@{
Layout = "TwoColumnLayout";
Layout = "TwoColumnLayout";
}

0 comments on commit d505f23

Please sign in to comment.