use of im.actor.core.network.parser.Request in project actor-platform by actorapp.
the class Authentication method requestStartEmailAuth.
@Deprecated
public Command<AuthState> requestStartEmailAuth(final String email) {
return callback -> {
ArrayList<String> langs1 = new ArrayList<>();
for (String s : modules.getConfiguration().getPreferredLanguages()) {
langs1.add(s);
}
request(new RequestStartEmailAuth(email, apiConfiguration.getAppId(), apiConfiguration.getAppKey(), deviceHash, apiConfiguration.getDeviceTitle(), modules.getConfiguration().getTimeZone(), langs1), new RpcCallback<ResponseStartEmailAuth>() {
@Override
public void onResult(ResponseStartEmailAuth response) {
modules.getPreferences().putString(KEY_EMAIL, email);
modules.getPreferences().putString(KEY_TRANSACTION_HASH, response.getTransactionHash());
ApiEmailActivationType emailActivationType = response.getActivationType();
if (emailActivationType.equals(ApiEmailActivationType.OAUTH2)) {
state = AuthState.GET_OAUTH_PARAMS;
} else if (emailActivationType.equals(ApiEmailActivationType.CODE)) {
state = AuthState.CODE_VALIDATION_EMAIL;
} else if (emailActivationType.equals(ApiEmailActivationType.PASSWORD)) {
state = AuthState.PASSWORD_VALIDATION;
} else {
state = AuthState.CODE_VALIDATION_EMAIL;
}
Runtime.postToMainThread(() -> callback.onResult(state));
}
@Override
public void onError(final RpcException e) {
Runtime.postToMainThread(() -> {
Log.e(TAG, e);
callback.onError(e);
});
}
});
};
}
use of im.actor.core.network.parser.Request in project actor-platform by actorapp.
the class Authentication method requestCompleteOauth.
@Deprecated
public Command<AuthState> requestCompleteOauth(final String code) {
return callback -> request(new RequestCompleteOAuth2(modules.getPreferences().getString(KEY_TRANSACTION_HASH), code), new RpcCallback<ResponseAuth>() {
@Override
public void onResult(ResponseAuth response) {
onLoggedIn(callback, response);
}
@Override
public void onError(final RpcException e) {
if ("EMAIL_EXPIRED".equals(e.getTag())) {
resetAuth();
} else if ("EMAIL_UNOCCUPIED".equals(e.getTag())) {
// modules.getPreferences().putString(KEY_CODE, code);
state = AuthState.SIGN_UP;
callback.onResult(AuthState.SIGN_UP);
return;
}
Runtime.postToMainThread(() -> {
Log.e(TAG, e);
callback.onError(e);
});
}
});
}
Aggregations