コード例 #1
0
        public void AddAuthIdentity(AuthIdentity authIdentity, Action onComplete, Action <GetSocialError> onFailure, Action <ConflictUser> onConflict)
        {
            var identity = authIdentity.ToRpcModel();

            LogRequest("addIdentity", identity);

            WithHadesClient(client =>
            {
                try
                {
                    User = client.addIdentity(SessionId, authIdentity.ToRpcModel());
                    Ui(() =>
                    {
                        LogResponse("addIdentity", User);
                        onComplete.SafeCall();
                    });
                }
                catch (THErrors errors)
                {
                    var errorCode = errors.Errors.First().ErrorCode;
                    if (errorCode == THErrorCode.EMResourceAlreadyExists ||
                        errorCode == THErrorCode.IdentityAlreadyExists)
                    {
                        var conflictUser = client.getPrivateUserByIdentity(SessionId, identity).ToConflictUser();
                        Ui(() =>
                        {
                            LogResponse("addIdentity", "Conflict user: " + conflictUser);
                            onConflict.SafeCall(conflictUser);
                        });
                    }
                }
            }, onFailure);
        }
コード例 #2
0
        public void SwitchUser(AuthIdentity authIdentity, Action onSuccess, Action <GetSocialError> onFailure)
        {
            var request = new THSdkAuthRequest
            {
                AppId             = _stateController.AppId,
                SessionProperties = _stateController.SuperProperties
            };

            var identity = authIdentity.ToRpcModel();

            LogRequest("switchUser", identity);

            WithHadesClient(client =>
            {
                var user = client.getPrivateUserByIdentity(SessionId, identity);

                request.UserId   = user.Id;
                request.Password = user.Password;

                var response = client.authenticateSdk(request);

                Ui(() =>
                {
                    LogResponse("switchUser", response);
                    _stateController.SaveSession(response.SessionId, response.User);
                    onSuccess.SafeCall();
                });
            }, onFailure);
        }