mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-20 16:22:27 +00:00
Move servers to LBPU.PL.Servers
This commit is contained in:
parent
545b5a0709
commit
b2ec7eae57
116 changed files with 173 additions and 162 deletions
|
@ -1,46 +0,0 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Profiles.Email;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using LBPUnion.ProjectLighthouse.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Website.Pages;
|
||||
|
||||
public class CompleteEmailVerificationPage : BaseLayout
|
||||
{
|
||||
public CompleteEmailVerificationPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public string? Error;
|
||||
|
||||
public async Task<IActionResult> OnGet(string token)
|
||||
{
|
||||
if (!ServerConfiguration.Instance.Mail.MailEnabled) return this.NotFound();
|
||||
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
EmailVerificationToken? emailVerifyToken = await this.Database.EmailVerificationTokens.FirstOrDefaultAsync(e => e.EmailToken == token);
|
||||
if (emailVerifyToken == null)
|
||||
{
|
||||
this.Error = "Invalid verification token";
|
||||
return this.Page();
|
||||
}
|
||||
|
||||
if (emailVerifyToken.UserId != user.UserId)
|
||||
{
|
||||
this.Error = "This token doesn't belong to you!";
|
||||
return this.Page();
|
||||
}
|
||||
|
||||
this.Database.EmailVerificationTokens.Remove(emailVerifyToken);
|
||||
|
||||
user.EmailAddressVerified = true;
|
||||
|
||||
await this.Database.SaveChangesAsync();
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue