private IAsyncAction SetViewPropeties(WebAccount account, Uri appCallbackUri, WebAccountClientViewType viewType) { WebAccountClientView view = null; if (viewType == WebAccountClientViewType.IdAndProperties) { view = new WebAccountClientView(WebAccountClientViewType.IdAndProperties, appCallbackUri); } else { view = new WebAccountClientView(WebAccountClientViewType.IdOnly, appCallbackUri); } return(Windows.Security.Authentication.Web.Provider.WebAccountManager.SetViewAsync(account, view)); }
private async void submitButton_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(userName.Text) && !string.IsNullOrEmpty(accountId.Text) ) { if (_requestedAccount == null) { WebAccountScope scope = WebAccountScope.PerUser; if (chkPerUserPerAppScope.IsChecked.Value) { scope = WebAccountScope.PerApplication; } if (string.IsNullOrEmpty(accountId.Text)) { accountId.Text = userName.Text; } var account = await AddWebAccount(userName.Text, accountId.Text, _operation.ProviderRequest.ClientRequest.Properties, chkPerUserScope.IsChecked.Value, chkPerUserPerAppScope.IsChecked.Value, perUserPerAppId.Text); if (chkPerUserPerAppScope.IsChecked.Value) { WebAccountClientViewType viewType = WebAccountClientViewType.IdOnly; if (chkFullView.IsChecked.Value) { viewType = WebAccountClientViewType.IdAndProperties; } await SetViewPropeties(account, _operation.ProviderRequest.ApplicationCallbackUri, viewType); } //TODO: is there more if (account != null) { _requestedAccount = account; } } //TODO: when does this happen? else { Debug.Assert(false); } if (_requestedAccount != null) { var tokenResponse = await CreateTokenResponse(_requestedAccount); _operation.ProviderResponses.Add(tokenResponse); _operation.CacheExpirationTime = DateTimeOffset.Now.AddDays(1); _operation.ReportCompleted(); } else { _operation.ReportError(CreateProviderError(Constants.ErrorCodes.AddAccountFailed)); } } else { ++_failedAttempts; if (_failedAttempts < MaxFailedAttempts) { errorMessage.Text = Constants.FormatError (Constants.UserNameAccountIdRequired, MaxFailedAttempts - _failedAttempts); } else { _operation.ReportError(CreateProviderError(Constants.ErrorCodes.InvalidPassword)); } } }