public async Task <int> Handle(RegisterUserCommand request, CancellationToken cancellationToken) { var db = _instanceDB.Get <IUserDbManager>(); var base64EncodedPwd = System.Convert.FromBase64String(request.User.Password); var passWord = System.Text.Encoding.UTF8.GetString(base64EncodedPwd); request.User.Password = _hashHelper.GetMD5Hash(passWord); var result = await db.RegisterUser(request.User); return(result); }
public async Task <UserAuthResult> Handle(AuthenticateUserCommand request, CancellationToken cancellationToken) { UserAuthResult userAuthResult = null; var db = _instanceDB.Get <IUserDbManager>(); var base64EncodedPwd = Convert.FromBase64String(request.Password); var passWord = Encoding.UTF8.GetString(base64EncodedPwd); passWord = _hashHelper.GetMD5Hash(passWord); Domain.Models.User user = await db.AuthenticateUser(request.Name, passWord); if (user != null) { userAuthResult = new UserAuthResult { AuthToken = _userAccessor.GenerateToken(user, _applicationSettingAccessor.Value.AuthenticationTokenSecret), UserId = user.Id }; } return(userAuthResult); }