public AuthResponseModel Login(AuthRequestModel authRequest) { var user = FindSingleOrNull<User>(u => u.UserName == authRequest.UserName); if (user != null && Cryptography.HashPassword( authRequest.Password, user.PasswordSalt) == user.PasswordHash) { user.AuthToken = Guid.NewGuid().ToString("N"); user.AuthExpiration = authRequest.Remember ? DateTime.UtcNow.AddDays(16) : DateTime.UtcNow.AddHours(4); UpdateAndSave(user); var authResponse = Map<AuthResponseModel>(user); authResponse.Succeeded = true; authResponse.DaysUntilExpiration = authRequest.Remember ? 16 : (int?)null; return authResponse; } else { return new AuthResponseModel { Succeeded = false }; } }
public AuthResponseModel Login(AuthRequestModel authRequest) { return Service<AuthService>().Login(authRequest); }