Search in sources :

Example 1 with ResponseStartEmailAuth

use of im.actor.core.api.rpc.ResponseStartEmailAuth 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);
                });
            }
        });
    };
}
Also used : ApiPhoneActivationType(im.actor.core.api.ApiPhoneActivationType) ResponseStartEmailAuth(im.actor.core.api.rpc.ResponseStartEmailAuth) RequestSendCodeByPhoneCall(im.actor.core.api.rpc.RequestSendCodeByPhoneCall) RequestSignUp(im.actor.core.api.rpc.RequestSignUp) Promise(im.actor.runtime.promise.Promise) Request(im.actor.core.network.parser.Request) PromiseFunc(im.actor.runtime.promise.PromiseFunc) ResponseStartPhoneAuth(im.actor.core.api.rpc.ResponseStartPhoneAuth) ArrayList(java.util.ArrayList) AbsModule(im.actor.core.modules.AbsModule) AuthCodeRes(im.actor.core.entity.AuthCodeRes) User(im.actor.core.entity.User) RequestGetOAuth2Params(im.actor.core.api.rpc.RequestGetOAuth2Params) Response(im.actor.core.network.parser.Response) Modules(im.actor.core.modules.Modules) im.actor.runtime(im.actor.runtime) RequestValidateCode(im.actor.core.api.rpc.RequestValidateCode) RpcCallback(im.actor.core.network.RpcCallback) ApiEmailActivationType(im.actor.core.api.ApiEmailActivationType) CommandCallback(im.actor.core.viewmodel.CommandCallback) Sex(im.actor.core.entity.Sex) RequestStartEmailAuth(im.actor.core.api.rpc.RequestStartEmailAuth) Command(im.actor.core.viewmodel.Command) AuthRes(im.actor.core.entity.AuthRes) ResponseStartUsernameAuth(im.actor.core.api.rpc.ResponseStartUsernameAuth) ApiConfiguration(im.actor.core.ApiConfiguration) ResponseGetOAuth2Params(im.actor.core.api.rpc.ResponseGetOAuth2Params) AuthStartRes(im.actor.core.entity.AuthStartRes) ResponseAuth(im.actor.core.api.rpc.ResponseAuth) IOException(java.io.IOException) AuthState(im.actor.core.AuthState) Runtime(im.actor.runtime.Runtime) RequestStartUsernameAuth(im.actor.core.api.rpc.RequestStartUsernameAuth) RpcException(im.actor.core.network.RpcException) ConnectionEndpoint(im.actor.runtime.mtproto.ConnectionEndpoint) TrustedKey(im.actor.core.network.TrustedKey) RequestStartPhoneAuth(im.actor.core.api.rpc.RequestStartPhoneAuth) ApiSex(im.actor.core.api.ApiSex) Endpoints(im.actor.core.network.Endpoints) ConnectionEndpointArray(im.actor.runtime.mtproto.ConnectionEndpointArray) ResponseVoid(im.actor.core.api.rpc.ResponseVoid) RequestCompleteOAuth2(im.actor.core.api.rpc.RequestCompleteOAuth2) RequestValidatePassword(im.actor.core.api.rpc.RequestValidatePassword) RequestStartAnonymousAuth(im.actor.core.api.rpc.RequestStartAnonymousAuth) AuthMode(im.actor.core.entity.AuthMode) ApiEmailActivationType(im.actor.core.api.ApiEmailActivationType) RequestStartEmailAuth(im.actor.core.api.rpc.RequestStartEmailAuth) ResponseStartEmailAuth(im.actor.core.api.rpc.ResponseStartEmailAuth) RpcException(im.actor.core.network.RpcException) ArrayList(java.util.ArrayList) RpcCallback(im.actor.core.network.RpcCallback)

Aggregations

ApiConfiguration (im.actor.core.ApiConfiguration)1 AuthState (im.actor.core.AuthState)1 ApiEmailActivationType (im.actor.core.api.ApiEmailActivationType)1 ApiPhoneActivationType (im.actor.core.api.ApiPhoneActivationType)1 ApiSex (im.actor.core.api.ApiSex)1 RequestCompleteOAuth2 (im.actor.core.api.rpc.RequestCompleteOAuth2)1 RequestGetOAuth2Params (im.actor.core.api.rpc.RequestGetOAuth2Params)1 RequestSendCodeByPhoneCall (im.actor.core.api.rpc.RequestSendCodeByPhoneCall)1 RequestSignUp (im.actor.core.api.rpc.RequestSignUp)1 RequestStartAnonymousAuth (im.actor.core.api.rpc.RequestStartAnonymousAuth)1 RequestStartEmailAuth (im.actor.core.api.rpc.RequestStartEmailAuth)1 RequestStartPhoneAuth (im.actor.core.api.rpc.RequestStartPhoneAuth)1 RequestStartUsernameAuth (im.actor.core.api.rpc.RequestStartUsernameAuth)1 RequestValidateCode (im.actor.core.api.rpc.RequestValidateCode)1 RequestValidatePassword (im.actor.core.api.rpc.RequestValidatePassword)1 ResponseAuth (im.actor.core.api.rpc.ResponseAuth)1 ResponseGetOAuth2Params (im.actor.core.api.rpc.ResponseGetOAuth2Params)1 ResponseStartEmailAuth (im.actor.core.api.rpc.ResponseStartEmailAuth)1 ResponseStartPhoneAuth (im.actor.core.api.rpc.ResponseStartPhoneAuth)1 ResponseStartUsernameAuth (im.actor.core.api.rpc.ResponseStartUsernameAuth)1