Search in sources :

Example 1 with WsMethod

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");
    }
}
Also used : HttpResponse(oap.http.HttpResponse) WsMethod(oap.ws.WsMethod)

Aggregations

HttpResponse (oap.http.HttpResponse)1 WsMethod (oap.ws.WsMethod)1