mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
Dont show email-related pages if SMTP is disabled
This commit is contained in:
parent
813ee8122f
commit
b520eecd4e
4 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@ using JetBrains.Annotations;
|
|||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Profiles.Email;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
@ -18,6 +19,8 @@ public class CompleteEmailVerificationPage : BaseLayout
|
|||
|
||||
public async Task<IActionResult> OnGet(string token)
|
||||
{
|
||||
if (!ServerSettings.Instance.SMTPEnabled) return this.NotFound();
|
||||
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public class LoginForm : BaseLayout
|
|||
Logger.Log($"User {user.Username} (id: {user.UserId}) successfully logged in on web", LoggerLevelLogin.Instance);
|
||||
|
||||
if (user.PasswordResetRequired) return this.Redirect("~/passwordResetRequired");
|
||||
if (!user.EmailAddressVerified) return this.Redirect("~/login/sendVerificationEmail");
|
||||
if (ServerSettings.Instance.SMTPEnabled && !user.EmailAddressVerified) return this.Redirect("~/login/sendVerificationEmail");
|
||||
|
||||
return this.RedirectToPage(nameof(LandingPage));
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ public class SendVerificationEmailPage : BaseLayout
|
|||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
if (!ServerSettings.Instance.SMTPEnabled) return this.NotFound();
|
||||
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("/login");
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ using LBPUnion.ProjectLighthouse.Logging;
|
|||
using LBPUnion.ProjectLighthouse.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Profiles.Email;
|
||||
using LBPUnion.ProjectLighthouse.Types.Settings;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@ -22,6 +23,7 @@ public class SetEmailForm : BaseLayout
|
|||
|
||||
public async Task<IActionResult> OnGet(string? token = null)
|
||||
{
|
||||
if (!ServerSettings.Instance.SMTPEnabled) return this.NotFound();
|
||||
if (token == null) return this.Redirect("/login");
|
||||
|
||||
EmailSetToken? emailToken = await this.Database.EmailSetTokens.FirstOrDefaultAsync(t => t.EmailToken == token);
|
||||
|
@ -34,6 +36,8 @@ public class SetEmailForm : BaseLayout
|
|||
|
||||
public async Task<IActionResult> OnPost(string emailAddress, string token)
|
||||
{
|
||||
if (!ServerSettings.Instance.SMTPEnabled) return this.NotFound();
|
||||
|
||||
EmailSetToken? emailToken = await this.Database.EmailSetTokens.Include(t => t.User).FirstOrDefaultAsync(t => t.EmailToken == token);
|
||||
if (emailToken == null) return this.Redirect("/login");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue