Ejemplo n.º 1
0
        public void AuthorizeGuest(OnAuthorizationSuccessDelegate OnSuccessDelegate, OnAuthorizationFailedDelegate OnFailedDelegate)
        {
            session = new QuartersSession();

            if (!string.IsNullOrEmpty(session.RefreshToken))
            {
                Debug.LogError("Authorization error. Registered user session exist. Use Authorize User call instead, or Deauthorize Quarters user first");
                return;
            }

            this.OnAuthorizationSuccess = OnSuccessDelegate;
            this.OnAuthorizationFailed  = OnFailedDelegate;

            if (IsAuthorized)
            {
                this.OnAuthorizationSuccess();
                return;
            }

            if (OnAuthorizationStart != null)
            {
                OnAuthorizationStart();
            }

            //create new guest account
            StartCoroutine(CreateNewGuestUser());
        }
Ejemplo n.º 2
0
        public void Deauthorize()
        {
            this.session.Invalidate();
            this.session = null;
            CurrentUser  = null;

            //clean up delegates
            OnAuthorizationStart       = null;
            OnAuthorizationSuccess     = null;
            OnAuthorizationFailed      = null;
            currentTransferAPIRequests = new List <TransferAPIRequest>();
        }
Ejemplo n.º 3
0
        public void Authorize(OnAuthorizationSuccessDelegate OnSuccessDelegate, OnAuthorizationFailedDelegate OnFailedDelegate, bool forceExternalBrowser = false)
        {
            if (!forceExternalBrowser && Application.platform == RuntimePlatform.WindowsEditor)
            {
                Debug.LogWarning("Quarters: WebView is not supported in Unity Editor on Windows. Falling back to forcing external browser. You can safely ignore this message");
                forceExternalBrowser = true;
            }


            session = new QuartersSession();

            this.OnAuthorizationSuccess = OnSuccessDelegate;
            this.OnAuthorizationFailed  = OnFailedDelegate;

            if (IsAuthorized)
            {
                this.OnAuthorizationSuccess();
                return;
            }


            Debug.Log("Quarters: Authorize new session");

            if (OnAuthorizationStart != null)
            {
                OnAuthorizationStart();
            }

            if (Application.isEditor && forceExternalBrowser)
            {
                //spawn editor UI
                GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("QuartersEditor"));
                AuthorizeEditor();
            }
            else
            {
                //direct to the browser
                AuthorizeExternal();
            }
        }