public static (HttpStatusCode statusCode, ErrorCode errorCode) ParseException(this Exception exception) { return(exception switch { NotFoundException _ => (HttpStatusCode.NotFound, ErrorCode.NotFound), InvalidUsernameOrPasswordException _ => (HttpStatusCode.Unauthorized, ErrorCode.InvalidUsernameOrPassword), InvalidTokenException _ => (HttpStatusCode.Unauthorized, ErrorCode.InvalidToken), ExpiredRefreshTokenException _ => (HttpStatusCode.Unauthorized, ErrorCode.ExpiredRefreshToken), _ => (HttpStatusCode.InternalServerError, ErrorCode.General), });
private Login(ITokenRepository tokenRepository, IUserRepository userRepository, ITokenCreator tokenCreator, string appKey, string userName, string password, string device) { _tokenRepository = tokenRepository; _userRepository = userRepository; _appKey = appKey; _userName = userName; _password = password; _tokenCreator = tokenCreator; _device = device; ValidateInstance(); InvalidUsernameOrPasswordExceptionCreator = () => InvalidUsernameOrPasswordException.Create(_userName, _appKey); }