/// <summary> /// Login the specified user. /// </summary> /// <returns>The login.</returns> /// <param name="user">User.</param> public LoginStatus Login(IUser user) { try { if (_users.ContainsKey(user.EmailAddress)) { if (CryptographyController.EncryptPassword(user.Password).Equals(_users[user.EmailAddress])) { return(LoginStatus.Success); } return(LoginStatus.InvalidPassword); } return(LoginStatus.UserDoesNotExist); } catch { return(LoginStatus.Failed); } }
/// <summary> /// Register the specified user. /// </summary> /// <returns>The register.</returns> /// <param name="user">User.</param> public RegistrationStatus Register(IUser user) { var status = CheckUserExists(user); if (status == RegistrationStatus.NewUser) { try { string encrypterPassword = CryptographyController.EncryptPassword(user.Password); Users.Add(user.EmailAddress, encrypterPassword); status = RegistrationStatus.Success; } catch { status = RegistrationStatus.Failed; } } return(status); }