Search in sources :

Example 1 with ConnectionRegistry

use of org.nustaq.kontraktor.remoting.base.ConnectionRegistry in project kontraktor by RuedigerMoeller.

the class BasicWebAppActor method login.

/**
 * returns an array of [session actorproxy, userdata]
 * @param user
 * @param pw
 * @param jwt
 * @return array [session actor proxy, authenticationresult]
 */
@Remoted
public IPromise<Object[]> login(String user, String pw, String jwt) {
    Promise res = new Promise();
    ConnectionRegistry remoteConnection = connection.get();
    getCredentials(user, pw, jwt).then((authres, err) -> {
        if (err != null) {
            res.reject(err);
        } else {
            String sessionId = remoteConnection != null ? remoteConnection.getSocketRef().getConnectionIdentifier() : null;
            getSession(user, sessionId, authres).then((sess, serr) -> {
                if (sess != null) {
                    if (sessionId != null && sessionStorage != null) {
                        sessionStorage.putUserAtSessionId(sessionId, user);
                    }
                    res.resolve(new Object[] { sess, authres });
                } else
                    res.complete(sess, serr);
            });
        }
    });
    return res;
}
Also used : ConnectionRegistry(org.nustaq.kontraktor.remoting.base.ConnectionRegistry) Remoted(org.nustaq.kontraktor.annotations.Remoted)

Aggregations

Remoted (org.nustaq.kontraktor.annotations.Remoted)1 ConnectionRegistry (org.nustaq.kontraktor.remoting.base.ConnectionRegistry)1