mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-23 13:41:31 +00:00
Implement URL slugs (#931)
* Implement URL slugs for Users and Slots * Fix extra spaces in slot slugs
This commit is contained in:
parent
aea66b4a74
commit
1eb3bfa2ec
8 changed files with 55 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -38,11 +39,17 @@ public class UserPage : BaseLayout
|
|||
public UserPage(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int userId)
|
||||
public async Task<IActionResult> OnGet([FromRoute] int userId, string? slug)
|
||||
{
|
||||
this.ProfileUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == userId);
|
||||
if (this.ProfileUser == null) return this.NotFound();
|
||||
|
||||
string userSlug = this.ProfileUser.GenerateSlug();
|
||||
if (slug == null || userSlug != slug)
|
||||
{
|
||||
return this.Redirect($"~/user/{userId}/{userSlug}");
|
||||
}
|
||||
|
||||
bool isAuthenticated = this.User != null;
|
||||
bool isOwner = this.ProfileUser == this.User || this.User != null && this.User.IsModerator;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue