Mani Pazhana
asked on
MVC - RegisterViewModel and ResetPasswordViewModel
Hello Experts,
I am using MVC 5 with razor C#:
I have a requirement that will:
• Force user to reset password on first login.
• Require a more robust password on password reset. 8 digits with at least one letter and at least one number.
so far I have this code:
public class RegisterViewModel
{
[Required]
[Display(Name = "User Name")]
public string UserName { get; set; }
//[Required]
//[EmailAddress]
//[Display(Name = "Email")]
//public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Passwor d)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Passwor d)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
//[Display(Name = "Hometown")]
//public string Hometown { get; set; }
}
public class ResetPasswordViewModel
{
[Required]
[Display(Name = "User Name")]
public string UserName { get; set; }
//[Required]
//[EmailAddress]
//[Display(Name = "Email")]
//public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Passwor d)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Passwor d)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
public string Code { get; set; }
}
-------------------------- --------
Any idea?
Thanks
I am using MVC 5 with razor C#:
I have a requirement that will:
• Force user to reset password on first login.
• Require a more robust password on password reset. 8 digits with at least one letter and at least one number.
so far I have this code:
public class RegisterViewModel
{
[Required]
[Display(Name = "User Name")]
public string UserName { get; set; }
//[Required]
//[EmailAddress]
//[Display(Name = "Email")]
//public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Passwor
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Passwor
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
//[Display(Name = "Hometown")]
//public string Hometown { get; set; }
}
public class ResetPasswordViewModel
{
[Required]
[Display(Name = "User Name")]
public string UserName { get; set; }
//[Required]
//[EmailAddress]
//[Display(Name = "Email")]
//public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Passwor
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Passwor
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
public string Code { get; set; }
}
--------------------------
Any idea?
Thanks
Idea about what specifically? You listed two requirements and then two model classes. What's is/are the actual question(s)?
ASKER
i want to know how to code this logic:
Force user to reset password on first login. I am using MVC5/ Razor C#/ Owin Security model.
using Microsoft.Owin.Security;
Backend User Table:
SELECT TOP 1000 [Id]
,[Email]
,[EmailConfirmed]
,[PasswordHash]
,[SecurityStamp]
,[PhoneNumber]
,[PhoneNumberConfirmed]
,[TwoFactorEnabled]
,[LockoutEndDateUtc]
,[LockoutEnabled]
,[AccessFailedCount]
,[UserName]
,[UserPassword]
FROM [AAONExtranet].[dbo].[AspN etUsers]
I am planning to add a column to the table([AAONExtranet].[dbo] .[AspNetUs ers]) at the end:
IsUserLoggedIn bool (Default: False)
When they login for first time, we check the flag; if it is False; redirect them to ChangePassword.
On successful change, we will set the flag to True.
Do you have any other suggestion?
Thanks
Force user to reset password on first login. I am using MVC5/ Razor C#/ Owin Security model.
using Microsoft.Owin.Security;
Backend User Table:
SELECT TOP 1000 [Id]
,[Email]
,[EmailConfirmed]
,[PasswordHash]
,[SecurityStamp]
,[PhoneNumber]
,[PhoneNumberConfirmed]
,[TwoFactorEnabled]
,[LockoutEndDateUtc]
,[LockoutEnabled]
,[AccessFailedCount]
,[UserName]
,[UserPassword]
FROM [AAONExtranet].[dbo].[AspN
I am planning to add a column to the table([AAONExtranet].[dbo]
IsUserLoggedIn bool (Default: False)
When they login for first time, we check the flag; if it is False; redirect them to ChangePassword.
On successful change, we will set the flag to True.
Do you have any other suggestion?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.