use of oap.ws.WsMethod in project oap by oaplatform.
the class LoginWS method login.
@WsMethod(method = GET, path = "/")
public HttpResponse login(@WsParam(from = QUERY) String email, @WsParam(from = QUERY) String password) {
final Optional<Token> optionalToken = authService.generateToken(email, password);
if (optionalToken.isPresent()) {
final Token token = optionalToken.get();
final HttpResponse ok = HttpResponse.ok(token);
return withAuthorization(ok, token);
} else {
return HttpResponse.status(HTTP_UNAUTHORIZED, "Username or password is invalid");
}
}
Aggregations