private static bool create_database_user(PurpleAccount user, string password) { PurplePassword PuPa = new PurplePassword (); user.password = PuPa.CreateHash(password); user.NewGuid(); user.account_created = DateTime.Now; user.account_type = "User"; user.active = false; if(PurpleAttributes.Validator.Validate (user, out errorList)) { int result = user.ToSQLInsert ().Execute (); if(result == 1) PurpleMailGenerator.SendMail(PurpleConfig.Mail.Template.Register, user); return (result==1) ? true : false; } return false; }
public void Password_Fail() { string password = "******"; PurplePassword PurplePasswordInstance = new PurplePassword (); string passwordHash = PurplePasswordInstance.CreateHash (password); Assert.IsFalse(PurplePasswordInstance.ValidatePassword ("WrongPassword987?", passwordHash)); }
public static bool ValidateAuthentication(string identifier, string password_or_token) { PurpleAccount userData = get_user_reference (identifier); if(userData == null) return false; if(!string.IsNullOrEmpty(password_or_token)) { PurplePassword pp = new PurplePassword(); if(pp.ValidatePassword(password_or_token, userData.password)) { update_user_last_seen(userData); return true; } if(!String.IsNullOrEmpty(userData.token) && password_or_token == userData.token) { if(PurpleHash.GetTokenDate(userData.token) .AddDays(PurpleConfig.Account.User.Token.DaysValid) >= DateTime.Now) { update_user_last_seen(userData); return true; } } } return false; }
public void Password() { string password = "******"; PurplePassword PurplePasswordInstance = new PurplePassword (); string passwordHash = PurplePasswordInstance.CreateHash (password); Assert.IsTrue(PurplePasswordInstance.ValidatePassword (password, passwordHash)); }