public Encrypted <AddictionalData> SyncAddictionalData(Encrypted <AddictionalData> encryptedData) { return(Handle((user) => { WarningHandler.InfoFormat("User AddictionalData sync: [{0}];", user.Name); var data = encryptedData.Decrypt(_secretKey); AddictionalDataManager.Handle(data, user); var preparedData = AddictionalDataManager.Prepare(user); return new Encrypted <AddictionalData>(preparedData, _secretKey); })); }
public override void Validate(string userName, string password) { try { WarningHandler.Debug("Authentication try: " + userName); var passwordHash = CryptoUtils.CreatePasswordHash(password); var user = UsersRepository.Users.SingleOrDefault(x => x.Login.Equals(userName) && x.PasswordHash.Equals(passwordHash)); if (user == null) { throw new FaultException("Login or password not valid", new FaultCode(ServiceFaultCodes.AccessDenied)); } WarningHandler.Debug("Authentication success: " + userName); } catch (FaultException e) { WarningHandler.Debug("Authentication failed: " + userName); throw e; } catch (Exception e) { WarningHandler.InfoFormat(e, "Error while user authenticate: [{0}]", userName); throw new FaultException("Error while user authenticate: " + userName, new FaultCode(ServiceFaultCodes.InternalError)); } }