48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using PlotLine.Models;
|
|
using PlotLine.ViewModels;
|
|
|
|
namespace PlotLine.Services;
|
|
|
|
public interface IAuthService
|
|
{
|
|
Task<RegistrationResult> RegisterAsync(RegisterViewModel model);
|
|
Task<AuthenticationResult> LoginAsync(LoginViewModel model);
|
|
Task<AuthenticationResult> CompleteTwoFactorLoginAsync(TwoFactorViewModel model);
|
|
Task LogoutAsync();
|
|
Task<AuthenticationResult> VerifyEmailAsync(Guid token);
|
|
Task<AuthenticationResult> ForgotPasswordAsync(ForgotPasswordViewModel model);
|
|
Task<AuthenticationResult> ResetPasswordAsync(ResetPasswordViewModel model);
|
|
Task<AuthenticationResult> ChangePasswordAsync(ChangePasswordViewModel model);
|
|
Task<AuthenticationResult> EnableTwoFactorAsync(int userId);
|
|
Task<AuthenticationResult> DisableTwoFactorAsync(int userId);
|
|
Task<IReadOnlyList<string>> GenerateRecoveryCodesAsync(int userId);
|
|
}
|
|
|
|
public interface IPasswordService
|
|
{
|
|
string HashPassword(string password);
|
|
bool VerifyPassword(string password, string passwordHash);
|
|
}
|
|
|
|
public interface ITwoFactorService
|
|
{
|
|
string GenerateSecretKey();
|
|
string GenerateQrCodeUri(string email, string secretKey);
|
|
bool ValidateCode(string secretKey, string code);
|
|
IReadOnlyList<string> GenerateRecoveryCodes(int count);
|
|
}
|
|
|
|
public interface IEmailService
|
|
{
|
|
Task SendVerificationEmailAsync(string email, string displayName, Guid token);
|
|
Task SendPasswordResetEmailAsync(string email, string displayName, Guid token);
|
|
}
|
|
|
|
public interface ICurrentUserService
|
|
{
|
|
int? UserId { get; }
|
|
string? Email { get; }
|
|
string? DisplayName { get; }
|
|
bool IsAuthenticated { get; }
|
|
}
|