public IDataResult <AccessToken> CreateAccessToken(User user) { var claims = _userService.GetClaims(user); var accessToken = _tokenHelper.CreateAccessToken(user, claims); return(new SuccessDataResult <AccessToken>(accessToken, Message.AccessTokenCreated)); }
public Result <AccessToken> CreateAccestoken(User user) { var claims = userDAL.GetOperationClaims(user); var accessToken = _tokenHelper.CreateAccessToken(user, claims); return(new Result <AccessToken>(true, "basarili", accessToken)); }
public Result <AccessToken> CreateAccestoken(UserDTO user) { var userch = userDAL.Get(w => w.Email == user.Email); var claims = userDAL.GetOperationClaims(userch); var accessToken = _tokenHelper.CreateAccessToken(userch, claims); return(new Result <AccessToken>(true, "basarili", accessToken)); }
/// <summary> /// Creates and saves access and refresh token by email and password related user. /// </summary> /// <param name="email">User email</param> /// <param name="password">User password (must be hashed).</param> /// <returns><see cref="ObjectResponse{AccessToken}"/> that includes new <see cref="AccessToken"/> /// if success, error message otherwise.</returns> public async Task <ObjectResponse <AccessToken> > CreateTokenAsync(string email, string password) { ObjectResponse <User> userResponse = await _userService.FindFirstOrDefault(u => u.Email == email); if (userResponse.Success) { User user = userResponse.Object; if (user.PassWord != password) { return(new ObjectResponse <AccessToken>(Constants.ErrorMessages.Auth.WrongPassword)); } AccessToken token = _tokenHelper.CreateAccessToken(user); user.RefreshToken = token.RefreshToken; user.RefreshTokenExpirationDate = DateTime.Now.AddDays(_tokenHelper.GetTokenOptions().RefreshTokenExpiration); await _userService.UpdateAsync(user); return(new ObjectResponse <AccessToken>(token)); } return(new ObjectResponse <AccessToken>(Constants.ErrorMessages.Auth.WrongEmail)); }
/*public IDataResult<AccessToken> CreateAccessToken(User user) * { * /*Console.WriteLine(user.Id); * Console.WriteLine(user.Status); * Console.WriteLine(user.EMail); * Console.WriteLine(user.FirstName); * Console.WriteLine(user.LastName); * Console.WriteLine(user.PasswordHash); * Console.WriteLine(user.PasswordSalt); * Console.WriteLine(user);#1# * var result = _userService.GetUserOperationClaims(user); * * var userOperationClaimDtoList = result.Data; * * var operationClaimList = * userOperationClaimDtoList.Select(userOperationClaimDto => new OperationClaim * { * Id = userOperationClaimDto.OperationClaimId, * Name = userOperationClaimDto.OperationClaimName * }).ToList(); * * var accessToken = _tokenHelper.CreateAccessToken(user, operationClaimList); * return new SuccessDataResult<AccessToken>(Messages.AccessTokenCreated, accessToken); * }*/ private AccessToken CreateAccessTokenMine(User user) { var result = _userService.GetUserOperationClaims(user); var userOperationClaimDtoList = result.Data; var operationClaimList = userOperationClaimDtoList.Select(userOperationClaimDto => new OperationClaim { Id = userOperationClaimDto.OperationClaimId, Name = userOperationClaimDto.OperationClaimName }).ToList(); var accessToken = _tokenHelper.CreateAccessToken(user, operationClaimList); return(accessToken); }
public JsonResponses Get([FromQuery] AppToken appToken) { JsonResponses responses = JsonResponses.Failed; UcUsersSetting ucUsers = userSettingSdk.GetUserSettingInfo(appToken.UserNo); if (ucUsers == null) { responses.msg = LoginResultType.ERROR_USER_NOT_EXIST.ToString(); return(JsonResponses.Failed); } if (!(ucUsers.AppSecret.Equals(appToken.AppSecret) && ucUsers.AppId.Equals(appToken.AppId))) { responses.msg = LoginResultType.ERROR_PASSWORD_TOO_MUCH.ToString(); return(JsonResponses.Failed); } return(new JsonResponses(tokenHelper.CreateAccessToken(appToken))); }
public IDataResult <AccessToken> CreateAccessToken(User user) { return(new SuccessDataResult <AccessToken>(Messages.AccessTokenCreated, _tokenHelper.CreateAccessToken(user))); }