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
LVL 8
mani_saiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Craig WagnerSoftware ArchitectCommented:
Idea about what specifically? You listed two requirements and then two model classes. What's is/are the actual question(s)?
0
mani_saiAuthor Commented:
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
0
Gururaj BadamCommented:
The first model states that the user is going to key in required password while registering. If such is the case, why do you want to force the user to reset the password on first login?

If in case the user is provided with temporary password. You can add a new column to the table of type bool (IsTempPassword) and set it to true when a temporary password is issued. This will help you to redirect the user to password reset page. This column will also be helpful in case of forgot password as well.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.