//Reset Password public static Boolean GeneratePasswordResetToken(AccountViewModel_GeneratePasswordResetToken view, string ConnectionString, SecurityLogic security) { //Pre DAL Check if (view.LoginID == null) { view.Errors.Add("Please insert a valid Email"); } if (view.Errors.Count > 0) { return(false); } //Set Salt and Generate Password Reset Token view.salt = security.GenerateSalt(); AccountDataAccess.GeneratePasswordResetToken(view, ConnectionString, security); //Post DAl Validation Check if (view.AccountID == null) { return(false); } if (view.Email == null) { return(false); } if (view.Errors.Count > 0) { return(false); } return(true); }
public static Boolean ResetPassword(AccountViewModel_ResetPassword resetPasswordView, AccountViewModel_VerifyPasswordResetToken verifyTokenView, string ConnectionString, SecurityLogic security) { //Checks if a valid password was provided if (resetPasswordView.password == null || resetPasswordView.password == "") { resetPasswordView.Errors.Add("Please Provide a Password"); } if (resetPasswordView.Errors.Count > 0) { return(false); } //Checks for a valid Reset Password Token (AccountID > 0 signifies a successful VerifyPasswordResetToken Execution) if (verifyTokenView.AccountID > 0 || verifyTokenView.Errors.Count() == 0) { //Generates a Salt and Resets the Password resetPasswordView.passwordSalt = security.GenerateSalt(); if (AccountDataAccess.ResetPassword(resetPasswordView, verifyTokenView, ConnectionString, security)) { //Post Validation Checks if (resetPasswordView.AccountID == null) { return(false); } if (resetPasswordView.AccountID <= 0) { return(false); } if (resetPasswordView.Errors.Count > 0) { return(false); } return(true); } } return(false); }
//Register public static Boolean Registration(AccountViewModel_Registration view, string ConnectionString, SecurityLogic security) { if (view.Errors.Count > 0) { return(false); } //Generate Salt view.salt = security.GenerateSalt(); //Registers Account if (AccountDataAccess.Register(view, ConnectionString, security)) { //Post DAL Verifications if (view.AccountID == null || view.AccountID <= 0) { view.Errors.Add("An Unexpected error occured when Setting up the Account. Please Contact a System Admin for Further information (Invalid Account ID)"); } if (view.EmailVerificationKey == null) { view.Errors.Add("An Unexpected error occured when Setting up the Account. Please Contact a System Admin for Further information (Invalid Key)"); } if (view.EmailVerificationToken == null) { view.Errors.Add("An Unexpected error occured when Setting up the Account. Please Contact a System Admin for Further information (Invalid Token)"); } if (view.Errors.Count > 0) { return(false); } return(true); } return(false); }
public static Boolean UpdatePassword(AccountViewModel_UpdatePassword view, string ConnectionString, SecurityLogic security) { view.newsalt = security.GenerateSalt(); AccountDataAccess.GetSalt(view, ConnectionString); if (view.AccountID == null) { view.Errors.Add("Invalid Account Provided"); } if (view.Email == null) { view.Errors.Add("Invalid Email Provided"); } if (view.newsalt == null) { view.Errors.Add("Salt Not Provided"); } if (view.cursalt == null) { view.Errors.Add("Current Salt not Provided"); } if (view.Errors.Count > 0) { return(false); } if (AccountDataAccess.UpdatePassword(view, ConnectionString, security)) { return(true); } return(false); }