Reset password

 

Scenario:

Encryption using Asymmetric keys

Solution:

     
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    private static string[] GetOldPasswords(string userName, int count)
            {
                //Get from history table
            }
    
            public class PasswordManagement
            {
                public void Enqueue(string email)
                {
                    var newUserPassexpiry = DateTime.UtcNow.AddHours(72);
                    var oldUserPassexpiry = DateTime.UtcNow.AddHours(48);
    
                    var token = $"{email}:-:{newUserPassexpiry:oldUserPassexpiry}:-:{PassResetCnt}";
    
                    var url = $"{url}?{token}";
    
                    //enqueue email
                }
            }
         
     
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
            static void Main(string[] args)
            {
                //passwordHistory = 10 (count)
                string userName = "", password = "";
                var count = 10;
    
                var passwordHistory = GetOldPasswords(userName, count);
    
                //if existing password re used
                if (passwordHistory.where(p => p.password== password))
    { //error } var hash = CreateHash(password); }

No comments:

Post a Comment

Move Github Sub Repository back to main repo

 -- delete .gitmodules git rm --cached MyProject/Core git commit -m 'Remove myproject_core submodule' rm -rf MyProject/Core git remo...