private void HandleResult(GuestControllerResult <SiteConfigurationResponse> gcResult, Action <IInternalGetRegistrationConfigurationResult> callback)
    {
        SiteConfigurationResponse response = gcResult.Response;

        if (!gcResult.Success)
        {
            callback(new GetRegistrationConfigurationResult(success: false, null));
            return;
        }
        IInternalGetRegistrationConfigurationResult regConfigResult = GuestControllerErrorParser.GetRegConfigResult(response.error);

        if (regConfigResult != null)
        {
            callback(regConfigResult);
            return;
        }
        if (!ValidateResponse(response))
        {
            callback(new GetRegistrationConfigurationResult(success: false, null));
            return;
        }
        RegistrationConfiguration configuration = new RegistrationConfiguration(response.data, ageBandBuilder);

        callback(new GetRegistrationConfigurationResult(success: true, configuration));
    }
 private static void HandleGetClaimableChildrenResult(AbstractLogger logger, IMixWebCallFactory mixWebCallFactory, Action <IGetLinkedUsersResult> callback, GuestControllerResult <ChildrenResponse> result)
 {
     try
     {
         if (!result.Success || result.Response.error != null || result.Response.data == null)
         {
             callback(MakeGenericFailure());
         }
         else
         {
             LinkedUsersGetter.Get(logger, mixWebCallFactory, result.Response.data.children, delegate(LinkedUser[] users)
             {
                 callback((users == null) ? MakeGenericFailure() : new GetLinkedUsersResult(success: true, users));
             });
         }
     }
     catch (Exception arg)
     {
         logger.Critical("Unhandled exception: " + arg);
         callback(MakeGenericFailure());
     }
 }
 private static void HandleUpdateProfileResult(AbstractLogger logger, IDatabase database, string swid, IEpochTime epochTime, GuestControllerResult <ProfileResponse> result, IInternalRegistrationProfile profile, Action <IUpdateProfileResult> callback)
 {
     try
     {
         if (!result.Success)
         {
             callback(new UpdateProfileResult(success: false, null));
         }
         else
         {
             IList <IInvalidProfileItemError> registerProfileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
             if (result.Response.data == null)
             {
                 callback(new UpdateProfileResult(success: false, registerProfileItemErrors));
             }
             else
             {
                 ProfileData profileData = result.Response.data;
                 if (profileData.displayName != null)
                 {
                     database.UpdateSessionDocument(swid, delegate(SessionDocument doc)
                     {
                         doc.DisplayNameText           = profileData.displayName.displayName;
                         doc.ProposedDisplayName       = profileData.displayName.proposedDisplayName;
                         doc.ProposedDisplayNameStatus = profileData.displayName.proposedStatus;
                         doc.FirstName              = profileData.profile.firstName;
                         doc.AccountStatus          = profileData.profile.status;
                         doc.LastProfileRefreshTime = epochTime.Seconds;
                     });
                 }
                 profile.Update(profileData.profile, profileData.displayName, profileData.marketing);
                 callback(new UpdateProfileResult(success: true, registerProfileItemErrors));
             }
         }
     }
     catch (Exception arg)
     {
         logger.Critical("Unhandled exception: " + arg);
         callback(new UpdateProfileResult(success: false, null));
     }
 }
Ejemplo n.º 4
0
    private void HandleRegisterSuccess(GuestControllerResult <LogInResponse> result, IEnumerable <Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem> marketing, Action <IRegisterResult> callback)
    {
        IList <IInvalidProfileItemError> profileItemErrors = null;

        try
        {
            if (!result.Success)
            {
                callback(new RegisterResult(success: false, null, null));
            }
            else
            {
                IRegisterResult registerResult = GuestControllerErrorParser.GetRegisterResult(result.Response.error);
                if (registerResult != null)
                {
                    callback(registerResult);
                }
                else
                {
                    profileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
                    if (result.Response.data == null)
                    {
                        if (result.Response.error != null && profileItemErrors == null)
                        {
                            logger.Critical("Received unhandled error exception" + JsonParser.ToJson(result.Response.error));
                        }
                        callback(new RegisterResult(success: false, null, profileItemErrors));
                    }
                    else
                    {
                        LogInData loginData = result.Response.data;
                        if (loginData.displayName == null || loginData.etag == null || loginData.profile == null || loginData.token == null || loginData.token.access_token == null)
                        {
                            logger.Critical("Invalid login data:" + JsonParser.ToJson(loginData));
                            callback(new RegisterResult(success: false, null, profileItemErrors));
                        }
                        else
                        {
                            loginData.profile.status = GuestControllerErrorParser.GetAccountStatusCode(result.Response.error, loginData.profile.status);
                            string countryCode = GuestControllerUtils.GetCountryCode(loginData.profile);
                            database.StoreSession(loginData.token.swid, loginData.token.access_token, loginData.token.refresh_token, loginData.displayName.displayName, loginData.profile.firstName, loginData.etag, loginData.profile.ageBand, loginData.displayName.proposedDisplayName, loginData.displayName.proposedStatus, loginData.profile.status, updateLastProfileRefreshTime: true, countryCode);
                            mixSessionStarter.Start(loginData.token.swid, loginData.token.access_token, delegate
                            {
                                HandleMixSessionStartSuccess(profileItemErrors, loginData.token.swid, loginData.profile, loginData.displayName, marketing, callback);
                            }, delegate
                            {
                                callback(new RegisterResult(success: false, null, profileItemErrors));
                            });
                        }
                    }
                }
            }
        }
        catch (CorruptionException arg)
        {
            logger.Fatal("Corruption detected during registration: " + arg);
            callback(new RegisterCorruptionDetectedResult());
        }
        catch (Exception arg2)
        {
            logger.Critical("Unhandled exception: " + arg2);
            callback(new RegisterResult(success: false, null, profileItemErrors));
        }
    }
Ejemplo n.º 5
0
    private void HandleLoginSuccess(GuestControllerResult <LogInResponse> result, Action <ILoginResult> callback)
    {
        try
        {
            LogInResponse           response          = result.Response;
            LogInData               data              = response.data;
            GuestApiErrorCollection gcErrorCollection = response.error;
            ILoginResult            loginResult       = GuestControllerErrorParser.GetLoginResult(gcErrorCollection);
            bool   flag          = false;
            string hallPassToken = string.Empty;
            string swid          = string.Empty;
            if (data != null || loginResult == null)
            {
                goto IL_015d;
            }
            if (loginResult is ILoginFailedParentalConsentResult)
            {
                foreach (GuestApiError error in gcErrorCollection.errors)
                {
                    TemporaryToken data2 = error.data;
                    if (data2 != null)
                    {
                        flag          = true;
                        hallPassToken = data2.accessToken;
                        swid          = data2.swid;
                        break;
                    }
                }
                if (flag)
                {
                    goto IL_015d;
                }
                callback(loginResult);
            }
            else
            {
                callback(loginResult);
            }
            goto end_IL_0018;
IL_015d:
            if (data == null && !flag)
            {
                if (gcErrorCollection != null)
                {
                    logger.Critical("Received unhandled error exception: " + JsonParser.ToJson(gcErrorCollection));
                }
                callback(new LoginResult(success: false, null));
            }
            else if (flag)
            {
                database.StoreSession(swid, hallPassToken, null, null, null, null, null, null, null, null, updateLastProfileRefreshTime: false, null);
                IGuestControllerClient guestControllerClient = guestControllerClientFactory.Create(swid);
                ProfileGetter.GetProfile(logger, guestControllerClient, delegate(ProfileData profileData)
                {
                    if (profileData == null)
                    {
                        database.DeleteSession(swid);
                        callback(new LoginFailedParentalConsentResult());
                    }
                    else
                    {
                        StoreSession(swid, hallPassToken, null, profileData.etag, profileData.displayName, profileData.profile);
                        HandleRefreshProfileSuccess(callback, loginResult, gcErrorCollection, profileData.profile, profileData.displayName, profileData.marketing, swid, hallPassToken);
                    }
                });
            }
            else if (!ValidateLogInData(data))
            {
                logger.Critical("Error parsing the login data:" + JsonParser.ToJson(data));
                callback(new LoginResult(success: false, null));
            }
            else
            {
                Token token = data.token;
                StoreSession(token.swid, token.access_token, token.refresh_token, data.etag, data.displayName, data.profile);
                HandleRefreshProfileSuccess(callback, loginResult, gcErrorCollection, data.profile, data.displayName, data.marketing, token.swid, token.access_token);
            }
            end_IL_0018 :;
        }
        catch (CorruptionException arg)
        {
            logger.Fatal("Corruption detected during login: "******"Unhandled exception: " + arg2);
            callback(new LoginResult(success: false, null));
        }
    }
 private void HandleRefreshSuccess(Action <IRestoreLastSessionResult> callback, GuestControllerResult <RefreshResponse> result, SessionDocument lastSessionDoc)
 {
     try
     {
         GuestApiErrorCollection   error2 = result.Response.error;
         RefreshData               data   = result.Response.data;
         IRestoreLastSessionResult error  = GuestControllerErrorParser.GetRestoreLastSessionResult(error2);
         if (data == null && error != null)
         {
             if (error is IRestoreLastSessionFailedInvalidOrExpiredTokenResult && lastSessionDoc.AccountStatus == "AWAIT_PARENT_CONSENT")
             {
                 callback(new RestoreLastSessionFailedParentalConsentResult());
             }
             else
             {
                 callback(error);
             }
         }
         else if (data == null)
         {
             if (error2 != null)
             {
                 logger.Critical("Received unhandled error exception:\n" + JsonParser.ToJson(error2) + "\nResponse headers:\n" + string.Join("\n", (from h in result.ResponseHeaders
                                                                                                                                                    select h.Key + ": " + h.Value).ToArray()));
             }
             callback(new RestoreLastSessionResult(success: false, null));
         }
         else if (!ValidateRefreshData(data))
         {
             logger.Critical("Error parsing the refresh data: " + JsonParser.ToJson(data));
             callback(new RestoreLastSessionResult(success: false, null));
         }
         else
         {
             Token token = data.token;
             lastSessionDoc.GuestControllerAccessToken = token.access_token;
             lastSessionDoc.GuestControllerEtag        = data.etag;
             database.UpdateGuestControllerToken(token, data.etag);
             try
             {
                 IInternalSession session = sessionFactory.Create(lastSessionDoc.Swid);
                 session.Resume(delegate(IResumeSessionResult r)
                 {
                     HandleOfflineSessionResumed(r, session, error, callback);
                 });
             }
             catch (Exception arg)
             {
                 logger.Critical("Error creating session: " + arg);
                 callback(new RestoreLastSessionResult(success: false, null));
             }
         }
     }
     catch (CorruptionException arg2)
     {
         logger.Fatal("Corruption detected during session restoration: " + arg2);
         callback(new RestoreLastSessionCorruptionDetectedResult());
     }
     catch (Exception arg)
     {
         logger.Critical("Unhandled exception: " + arg);
         callback(new RestoreLastSessionResult(success: false, null));
     }
 }