Exemple #1
0
 public void RefreshProfile(Action <IRefreshProfileResult> callback)
 {
     ProfileGetter.GetProfile(logger, guestControllerClient, delegate(ProfileData profileData)
     {
         HandleRefreshProfile(profileData, callback);
     });
 }
        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 ex)
            {
                logger.Fatal("Corruption detected during login: "******"Unhandled exception: " + ex2);
                callback(new LoginResult(success: false, null));
            }
        }