Exemple #1
0
        private async Task WebAccountInvokedHandlerCoreAsync(WebAccountCommand command, WebAccountInvokedArgs eventArgs)
        {
            if (eventArgs.Action == WebAccountAction.Remove)
            {
                string loginProvider = command.WebAccount.WebAccountProvider.DisplayName;
                string providerKey   = command.WebAccount.UserName;

                RemoveLogin removeLogin = new RemoveLogin()
                {
                    LoginProvider = loginProvider,
                    ProviderKey   = providerKey
                };

                HttpResult result;
                using (AccountClient accountClient = ClientFactory.CreateAccountClient())
                {
                    result = await accountClient.RemoveLoginAsync(removeLogin);
                }

                if (result.Succeeded)
                {
                    if (loginProvider == localProvider)
                    {
                        settings.ClearPasswordCredentials();
                    }
                }
                else
                {
                    await ErrorDialog.ShowErrorsAsync(result.Errors);
                }
            }
        }
        public async Task <string> PasswordVaultLoginAsync()
        {
            PasswordCredential passwordCredential = settings.GetPasswordCredential();

            if (passwordCredential != null)
            {
                HttpResult <AccessTokenResponse> result;
                using (AccountClient accountClient = ClientFactory.CreateAccountClient())
                {
                    result = await accountClient.LoginAsync(passwordCredential.UserName, passwordCredential.Password);
                }
                if (result.Succeeded)
                {
                    return(result.Content.AccessToken);
                }
                settings.ClearPasswordCredentials();
            }
            return(null);
        }