public override APIResponse Add() { try { string Salt = SHA256.Instance().GetUniqueKey(255); string EmailRegex = new ConfigurableBusinessLogic().FetchSettingsFromDB(new Settings(SettingsKey: "REGEX_EMAIL")).GetSettingsValue(); string PasswordRegex = new ConfigurableBusinessLogic().FetchSettingsFromDB(new Settings(SettingsKey: "REGEX_PASSWORD")).GetSettingsValue(); Regex rEmail = new Regex(@EmailRegex); Regex rPassword = new Regex(@PasswordRegex); if (rEmail.IsMatch(UserProfileObj.GetEmail()) == false) { throw new ArgumentException("Invalid Argument : Invalid Email format"); } if (rPassword.IsMatch(UserProfileObj.GetPassword()) == false) { throw new ArgumentException("Invalid Argument : Invalid Password"); } UserProfileObj.SetSalt(Salt); UserProfileObj.SetHashedPassword(SHA256.Instance().hash(UserProfileObj.GetPassword() + UserProfileObj.GetSalt())); UserProfileObj.SetToken(SHA256.Instance().hash(UserProfileObj.GetEmail() + UserProfileObj.GetPassword() + DateTime.Now.ToString())); UserDataLayerTemplate = new DATALAYER.NormalUserTemplate(UserProfileObj); return(UserDataLayerTemplate.Add()); } catch (MySqlException mse) { Logger.Instance().Log(Info.Instance(), mse); throw mse; } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }
public SettingsFromDB() { ConfigurableBusinessLogicObj = new ConfigurableBusinessLogic(); }