public async Task <IActionResult> GetActivatedUserAccount(string token) { string userIdString = _jwtService.GetUserIdFromToken(token); if (string.IsNullOrEmpty(userIdString)) { return(BadRequest(new ErrorResponseFormat(Constants.Errors.NOT_VALID_TOKEN))); } Guid userId = new Guid(userIdString); UserModel user = await _accountService.GetUserByIdAsync(userId); if (user == null) { return(BadRequest(new ErrorResponseFormat(Constants.Errors.EXPIRED_TOKEN))); } AccountTokenModel accountToken = await _accountService.DeleteAccountTokenAsync(userId); if (accountToken == null) { return(BadRequest(new ErrorResponseFormat(Constants.Errors.EXPIRED_TOKEN))); } return(Ok(new { id = user.Id, token = _jwtService.GetJWTToken(user, new ClaimsService(_jwtSettings)) })); }
public async Task AddAccountTokenAsync(AccountTokenModel tokenModel) { await _repository.AddAccountTokenAsync(_mapper.Map <AccountToken>(tokenModel)); }