• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 556
  • Last Modified:

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
0
mani_sai
Asked:
mani_sai
1 Solution
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now