mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 00:18:39 +00:00
Small fixup and fix unit test conflicts
This commit is contained in:
parent
f77e5eeee2
commit
3fb1441ac1
3 changed files with 12 additions and 12 deletions
|
@ -57,7 +57,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
|||
|
||||
UserEntity? user = await this.database.UserFromGameToken(token);
|
||||
|
||||
StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText + "\n\n");
|
||||
StringBuilder announceText = new(ServerConfiguration.Instance.AnnounceText);
|
||||
|
||||
announceText.Replace("%user", user.Username);
|
||||
announceText.Replace("%id", token.UserId.ToString());
|
||||
|
@ -69,7 +69,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
|||
|
||||
if (EmailEnforcementConfiguration.Instance.EnableEmailEnforcement)
|
||||
{
|
||||
announceText.Append(BaseLayoutStrings.EmailEnforcementWarnMain.Translate(LocalizationManager.DefaultLang) + "\n\n");
|
||||
announceText.Append("\n\n" + BaseLayoutStrings.EmailEnforcementWarnMain.Translate(LocalizationManager.DefaultLang) + "\n\n");
|
||||
|
||||
if (user.EmailAddress == null)
|
||||
{
|
||||
|
@ -148,7 +148,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
|||
if (!SMTPHelper.IsValidEmail(this.database, email)) return this.BadRequest();
|
||||
|
||||
UserEntity? user = await this.database.UserFromGameToken(token);
|
||||
if (user == null || user.EmailAddressVerified) return this.Ok();
|
||||
if (user == null || user.EmailAddressVerified) return this.BadRequest();
|
||||
|
||||
user.EmailAddress = email;
|
||||
await SMTPHelper.SendVerificationEmail(this.database, mailService, user);
|
||||
|
|
|
@ -15,12 +15,12 @@ public class EmailEnforcementMiddleware : MiddlewareDBContext
|
|||
|
||||
public override async Task InvokeAsync(HttpContext context, DatabaseContext database)
|
||||
{
|
||||
// Split path into segments
|
||||
string[] pathSegments = context.Request.Path.ToString().Split("/", StringSplitOptions.RemoveEmptyEntries);
|
||||
if (EmailEnforcementConfiguration.Instance.EnableEmailEnforcement)
|
||||
{
|
||||
// Split path into segments
|
||||
string[] pathSegments = context.Request.Path.ToString().Split("/", StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (pathSegments[0] == "LITTLEBIGPLANETPS3_XML")
|
||||
{
|
||||
if (EmailEnforcementConfiguration.Instance.EnableEmailEnforcement)
|
||||
if (pathSegments[0] == "LITTLEBIGPLANETPS3_XML")
|
||||
{
|
||||
// Get user via GameToken
|
||||
GameTokenEntity? token = await database.GameTokenFromRequest(context.Request);
|
||||
|
@ -35,7 +35,7 @@ public class EmailEnforcementMiddleware : MiddlewareDBContext
|
|||
if (user == null)
|
||||
{
|
||||
// Send bad request status
|
||||
context.Response.StatusCode = StatusCodes.Status400BadRequest;
|
||||
context.Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||
await context.Response.WriteAsync("Not a valid user");
|
||||
|
||||
// Don't go to next in pipeline
|
||||
|
|
|
@ -224,7 +224,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>." + "\nuni
|
|||
|
||||
IActionResult result = await messageController.Filter(mailMock.Object);
|
||||
|
||||
Assert.IsType<OkResult>(result);
|
||||
Assert.IsType<BadRequestResult>(result);
|
||||
mailMock.Verify(x => x.SendEmailAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>." + "\nuni
|
|||
|
||||
IActionResult result = await messageController.Filter(mailMock.Object);
|
||||
|
||||
Assert.IsType<OkResult>(result);
|
||||
Assert.IsType<BadRequestResult>(result);
|
||||
mailMock.Verify(x => x.SendEmailAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>." + "\nuni
|
|||
|
||||
IActionResult result = await messageController.Filter(mailMock.Object);
|
||||
|
||||
Assert.IsType<OkResult>(result);
|
||||
Assert.IsType<BadRequestResult>(result);
|
||||
mailMock.Verify(x => x.SendEmailAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue