Link to home
Start Free TrialLog in
Avatar of Mani Pazhana
Mani PazhanaFlag for United States of America

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.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [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.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [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
Avatar of Craig Wagner
Craig Wagner
Flag of United States of America image

Idea about what specifically? You listed two requirements and then two model classes. What's is/are the actual question(s)?
Avatar of Mani Pazhana

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].[AspNetUsers]


I am planning to add a column to the table([AAONExtranet].[dbo].[AspNetUsers]) 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
ASKER CERTIFIED SOLUTION
Avatar of Gururaj Badam
Gururaj Badam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial