/// <exception cref="InstanceNotFoundException"/> /// <exception cref="IncorrectPasswordException"/> public LoginResult Login(string loginName, string password, bool passwordIsEncrypted) { UserProfile userProfile = UserProfileDao.FindByLoginName(loginName); String storedPassword = userProfile.enPassword; if (passwordIsEncrypted) { if (!password.Equals(storedPassword)) { throw new IncorrectPasswordException(loginName); } } else { if (!PasswordEncrypter.IsClearPasswordCorrect(password, storedPassword)) { throw new IncorrectPasswordException(loginName); } } return(new LoginResult(userProfile.usrId, userProfile.firstName, storedPassword, userProfile.language, userProfile.country)); }
public void ChangePassword(long userId, string oldClearPassword, string newClearPassword) { UserProfile userProfile; try { userProfile = UserProfileDao.Find(userId); } catch (InstanceNotFoundException <UserProfile> ex) { throw new InstanceNotFoundException <UserProfileDetails>(ex.Properties); } String storedPassword = userProfile.password; if (!PasswordEncrypter.IsClearPasswordCorrect(oldClearPassword, storedPassword)) { throw new IncorrectPasswordException(userProfile.userLogin); } userProfile.password = PasswordEncrypter.Crypt(newClearPassword); try { UserProfileDao.Update(userProfile); } catch (InstanceNotFoundException <UserProfile> ex) { throw new InternalErrorException(ex); } }
/// <exception cref="IncorrectPasswordException"/> /// <exception cref="InstanceNotFoundException"/> public void ChangePassword(long userProfileId, string oldClearPassword, string newClearPassword) { UserProfile userProfile = UserProfileDao.Find(userProfileId); String storedPassword = userProfile.enPassword; if (!PasswordEncrypter.IsClearPasswordCorrect(oldClearPassword, storedPassword)) { throw new IncorrectPasswordException(userProfile.loginName); } userProfile.enPassword = PasswordEncrypter.Crypt(newClearPassword); UserProfileDao.Update(userProfile); }
public LoginResult Login(String loginName, String password, Boolean passwordIsEncrypted) { UserProfile userProfile = UserProfileDao.FindByLoginName(loginName); String storedPassword = userProfile.enPassword; if (passwordIsEncrypted) { if (!password.Equals(storedPassword)) { throw new IncorrectPasswordException(loginName); } } else { if (!PasswordEncrypter.IsClearPasswordCorrect(password, storedPassword)) { throw new IncorrectPasswordException(loginName); } } try { CreditCard card = creditCardDao.FindDefaultUserIdCard(userProfile.usrId); return(new LoginResult(userProfile.usrId, userProfile.firstName, storedPassword, userProfile.language, userProfile.country, userProfile.role, userProfile.address, card.cardId, card.cardNumber)); } catch (InstanceNotFoundException) { return(new LoginResult(userProfile.usrId, userProfile.firstName, storedPassword, userProfile.language, userProfile.country, userProfile.role, userProfile.address)); } }
public LoginResult Login(string loginName, string password, bool passwordIsEncrypted) { UserProfile userProfile; try { userProfile = UserProfileDao.FindByLoginName(loginName); } catch (InstanceNotFoundException <UserProfile> ex) { throw new InstanceNotFoundException <UserProfileDetails>(ex.Properties); } catch (DuplicateInstanceException <UserProfile> ex) { throw new InternalErrorException(ex); } String storedPassword = userProfile.password; if (passwordIsEncrypted) { if (!password.Equals(storedPassword)) { throw new IncorrectPasswordException(loginName); } } else { if (!PasswordEncrypter.IsClearPasswordCorrect(password, storedPassword)) { throw new IncorrectPasswordException(loginName); } } return(new LoginResult(userProfile.userId, userProfile.firstName, storedPassword, userProfile.languageCode, userProfile.countryCode)); }