Merge branch 'main' into CleanupFix

This commit is contained in:
Marcel Baumgartner
2023-04-03 02:27:48 +02:00
committed by GitHub
7 changed files with 323 additions and 7 deletions

View File

@@ -23,4 +23,5 @@ public enum AuditLogType
CleanupEnabled,
CleanupDisabled,
CleanupTriggered,
PasswordChange,
}

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.App.Models.Misc;
public class LoginDataModel
{
[Required(ErrorMessage = "You need to enter an email address")]
[EmailAddress(ErrorMessage = "You need to enter a valid email address")]
public string Email { get; set; }
[Required(ErrorMessage = "You need to enter a password")]
[MinLength(8, ErrorMessage = "You need to enter a password with minimum 8 characters in lenght")]
public string Password { get; set; }
}

View File

@@ -46,8 +46,7 @@ public class TotpService
public async Task Enable()
{
var user = (await IdentityService.Get())!;
user.TotpEnabled = true;
user.TotpSecret = GenerateSecret();
UserRepository.Update(user);
@@ -55,6 +54,14 @@ public class TotpService
await AuditLogService.Log(AuditLogType.EnableTotp, user.Email);
}
public async Task EnforceTotpLogin()
{
var user = (await IdentityService.Get())!;
user.TotpEnabled = true;
UserRepository.Update(user);
}
public async Task Disable()
{
var user = (await IdentityService.Get())!;