Esempio n. 1
0
        /// <summary>
        /// Here we have two user authenticators that we need to run together, since we just purchased a competitor's site. They are, however, incompatible in their methods.
        /// </summary>
        public static void Main()
        {
            User clint = User.CreateUser("Clint Eastwood", "MakeMyDayPunk");

            IUserAuthenticator inHouseAuthenticator = new UserAuthenticator();

            if (inHouseAuthenticator.CanAuthenticate(clint))
            {
                Debug.WriteLine(clint.Name + " can access our site.");
            }
            else
            {
                // Go through the motions of the third-party authenticator, somewhat different to our in-house one.
                ThirdPartyAuthenticator thirdpartyAuthenticator = new ThirdPartyAuthenticator();
                thirdpartyAuthenticator.StoreCredentials(clint.Name, clint.Password);

                // ... and try to authenticate using them both
                if (thirdpartyAuthenticator.TryToAuthenciate())
                {
                    Debug.WriteLine(clint.Name + " can access this website");
                }
                else
                {
                    Debug.WriteLine(clint.Name + " cannot access this website");
                }
            }
        }
Esempio n. 2
0
        public async void OnLoginSuccess()
        {
            if (loginCheck())
            {
                loginCallback.Content = loginCallback.createPreConnectAutoLoginLayout();
                // grab token and go!
                GlobalStatusSingleton.maintainLogin = true;
                string result = await ThirdPartyAuthenticator.requestTokenAsync(ThirdPartyAuthenticator.METHOD_FACEBOOK, AccessToken.CurrentAccessToken.TokenString);

                if (result.Equals("Success"))
                {
                    GlobalStatusSingleton.facebookRefreshToken = AccessToken.CurrentAccessToken.TokenString;
                    // request token takes care of housekeeping issues, like setting the email address. goto login success steps.
                    loginCallback.LoginSuccess();
                }
            }
        }
Esempio n. 3
0
        public async Task <string> relogin()
        {
            string result = await ThirdPartyAuthenticator.requestTokenAsync(ThirdPartyAuthenticator.METHOD_FACEBOOK, GlobalStatusSingleton.facebookRefreshToken);

            return(result);
        }