Add submenus for settings and profile. Add logout button.

save-path-regex
Pat Hartl 2023-11-03 23:33:27 -05:00
parent 3f3d5b718b
commit d6eff92835
3 changed files with 25 additions and 38 deletions

View File

@ -15,49 +15,20 @@ namespace LANCommander.Areas.Identity.Pages.Account
{
public class LogoutModel : PageModel
{
private readonly SignInManager<User> _signInManager;
private readonly ILogger<LogoutModel> _logger;
private readonly SignInManager<User> SignInManager;
private readonly ILogger<LogoutModel> Logger;
public LogoutModel(SignInManager<User> signInManager, ILogger<LogoutModel> logger)
{
_signInManager = signInManager;
_logger = logger;
SignInManager = signInManager;
Logger = logger;
}
public async Task<IActionResult> OnGet(string returnUrl = null, bool force = false)
public async Task<IActionResult> OnGet()
{
if (force)
{
await _signInManager.SignOutAsync();
_logger.LogInformation("User logged out.");
await SignInManager.SignOutAsync();
if (returnUrl != null)
{
return LocalRedirect(returnUrl);
}
else
{
return LocalRedirect("/Identity/Account/Login");
}
}
return Page();
}
public async Task<IActionResult> OnPost(string returnUrl = null)
{
await _signInManager.SignOutAsync();
_logger.LogInformation("User logged out.");
if (returnUrl != null)
{
return LocalRedirect(returnUrl);
}
else
{
// This needs to be a redirect so that the browser performs a new
// request and the identity for the user gets updated.
return RedirectToPage();
}
return LocalRedirect("/");
}
}
}

View File

@ -1,4 +1,5 @@
@page "/Profile"
@page "/Profile/General"
@using Microsoft.AspNetCore.Components.Authorization;
@layout ProfileLayout
@inject UserManager<User> UserManager

View File

@ -12,9 +12,24 @@
<MenuItem RouterLink="/Redistributables">Redistributables</MenuItem>
<MenuItem RouterLink="/Servers">Servers</MenuItem>
<MenuItem RouterLink="/Files">Files</MenuItem>
<MenuItem RouterLink="/Settings">Settings</MenuItem>
<SubMenu Title="Settings">
<MenuItem RouterLink="/Settings/General">General</MenuItem>
<MenuItem RouterLink="/Settings/Users">Users</MenuItem>
<MenuItem RouterLink="/Settings/Authentication">Authentication</MenuItem>
<MenuItem RouterLink="/Settings/UserSaves">User Saves</MenuItem>
<MenuItem RouterLink="/Settings/Archives">Archives</MenuItem>
<MenuItem RouterLink="/Settings/Media">Media</MenuItem>
<MenuItem RouterLink="/Settings/IPXRelay">IPX Relay</MenuItem>
<MenuItem RouterLink="/Settings/Beacon">Beacon</MenuItem>
<MenuItem RouterLink="/Settings/Tools">Tools</MenuItem>
</SubMenu>
}
<MenuItem RouterLink="/Profile">Profile</MenuItem>
<SubMenu Title="Profile">
<MenuItem RouterLink="/Profile">General</MenuItem>
<MenuItem RouterLink="/Profile/ChangePassword">Change Password</MenuItem>
<MenuItem RouterLink="/Profile/Saves">Saves</MenuItem>
<MenuItem RouterLink="/Identity/Account/Logout">Logout</MenuItem>
</SubMenu>
</MainMenu>
<Content Style="padding: 24px; min-height: 100vh;">