2026-10-17 03:13:16 +02:00
|
|
|
using PrivaPub.ClientModels.Resources;
|
|
|
|
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace PrivaPub.ClientModels.User
|
|
|
|
|
{
|
|
|
|
|
// The login's email address, set only with its password and only once a code sent to it comes back
|
|
|
|
|
// (/clientapi/user/email, /email/verify).
|
|
|
|
|
public class EmailChangeForm
|
|
|
|
|
{
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
EmailAddress(ErrorMessageResourceName = "InvalidEmail", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
StringLength(254, ErrorMessageResourceName = "MaxLengthString", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "Email", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string Email { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
DataType(DataType.Password),
|
|
|
|
|
PasswordPropertyText(true),
|
|
|
|
|
StringLength(Constants.MaxPasswordLength, ErrorMessageResourceName = "MaxLengthString", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "Password", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string Password { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class EmailCodeForm
|
|
|
|
|
{
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
StringLength(16, MinimumLength = 6, ErrorMessageResourceName = "StringLengthMinMax", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "RecoveryCode", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string Code { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// what only the login's password may do (removing its email address)
|
|
|
|
|
public class PasswordForm
|
|
|
|
|
{
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
DataType(DataType.Password),
|
|
|
|
|
PasswordPropertyText(true),
|
|
|
|
|
StringLength(Constants.MaxPasswordLength, ErrorMessageResourceName = "MaxLengthString", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "Password", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string Password { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ViewAccount
|
|
|
|
|
{
|
|
|
|
|
public string UserName { get; set; }
|
|
|
|
|
public string Email { get; set; }
|
|
|
|
|
public bool IsEmailValidated { get; set; } = false;
|
|
|
|
|
public string PendingEmail { get; set; }//waiting for its code
|
|
|
|
|
public DateTime CreatedAt { get; set; }
|
2026-10-17 03:18:19 +02:00
|
|
|
public bool TwoFactorEnabled { get; set; } = false;
|
|
|
|
|
public int RecoveryCodesLeft { get; set; } = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// a code from the authenticator app (six digits) or a recovery code
|
|
|
|
|
public class TotpCodeForm
|
|
|
|
|
{
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
StringLength(32, MinimumLength = 6, ErrorMessageResourceName = "StringLengthMinMax", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "RecoveryCode", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string Code { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TotpDisableForm
|
|
|
|
|
{
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
DataType(DataType.Password),
|
|
|
|
|
PasswordPropertyText(true),
|
|
|
|
|
StringLength(Constants.MaxPasswordLength, ErrorMessageResourceName = "MaxLengthString", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "Password", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string Password { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
StringLength(32, MinimumLength = 6, ErrorMessageResourceName = "StringLengthMinMax", ErrorMessageResourceType = typeof(ErrorsResource)),
|
|
|
|
|
Display(Name = "RecoveryCode", ResourceType = typeof(FieldsNameResource))]
|
|
|
|
|
public string Code { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// what an authenticator app needs: the secret, as text and as the otpauth:// URI its QR code holds
|
|
|
|
|
public class ViewTotpSetup
|
|
|
|
|
{
|
|
|
|
|
public string Secret { get; set; }
|
|
|
|
|
public string OtpAuthUri { get; set; }
|
|
|
|
|
public string QrDataUri { get; set; }//an SVG image, as a data: URI
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// shown once: the recovery codes, and this device's new session (turning two-factor on ends every other one)
|
|
|
|
|
public class ViewTotpEnabled
|
|
|
|
|
{
|
|
|
|
|
public List<string> RecoveryCodes { get; set; } = [];
|
|
|
|
|
public JwtUser Session { get; set; }
|
2026-10-17 03:13:16 +02:00
|
|
|
}
|
|
|
|
|
}
|