public async Task <IActionResult> Authenticate(User user, CancellationToken cancellationToken) { var requestResult = new RequestResult <Authentication>(); var requestResultUser = await _iBusinessUsers.Authenticate(user, cancellationToken); requestResult.Add(requestResultUser); if (requestResultUser.Succeeded) { var requestRefreshToken = await _iBusinessRefreshTokens.Create(requestResultUser.Model.UserId, cancellationToken); requestResult.Add(requestRefreshToken); var requestResultAuthentication = _iBusinessAuthentications.Create(requestRefreshToken.Model.Token, requestResultUser.Model); requestResult.Add(requestResultAuthentication); if (requestResultAuthentication.Succeeded) { requestResult.Model = requestResultAuthentication.Model; } return(Ok(requestResult)); } else { return(Unauthorized(requestResult)); } }
public async Task <IActionResult> Authenticate(User user, CancellationToken cancellationToken) { var requestResult = new RequestResult <Authentication>(); var requestResultUser = await _iBUsers.Authenticate(user, cancellationToken); requestResult.Add(requestResultUser); if (requestResultUser.Succeeded) { var requestResultAuthentication = _iBAuthentications.Create(string.Empty, requestResultUser.Model); //ToDo: Implement Refresh Token requestResult.Add(requestResultAuthentication); if (requestResultAuthentication.Succeeded) { requestResult.Model = requestResultAuthentication.Model; } } return(Ok(requestResult)); }