protected override void OnPreRender(EventArgs e) { // let the code process a callback URL, if we are being redirected from the OAuth provider if (Request.QueryString["oauthCallback"] == "true" && !IsPostBack) { AuthorizationServiceViewControllerBase.HandleCallback(); } var items = new List <ProviderHelperItem>(); var userService = ApplicationContext.Current.Services.Get <IUserService>(); IList <IOAuthProvider> providerList = EntityFactory.GetRepository <IOAuthProvider>().FindAll(); IList <IUserOAuthToken> tokenList = EntityFactory.GetRepository <IUserOAuthToken>() .FindByProperty("User.Id", userService.UserId.Trim()); foreach (IOAuthProvider provider in providerList) { if ((provider.Integration.Enabled ?? false) && (!String.IsNullOrEmpty(provider.ClientId) && !String.IsNullOrEmpty(provider.Secret) && UserHasAccess(provider.ProviderKey))) { var item = new ProviderHelperItem(provider); foreach (IUserOAuthToken token in tokenList) { if (token.OAuthProvider.Id == provider.Id) { item.AccountName = token.AccountLoginName; item.IsAuthorized = true; } } items.Add(item); } } lblNoProviders.Visible = items.Count == 0; providerListView.DataSource = items; providerListView.DataBind(); }
protected override void OnPreRender(EventArgs e) { // let the code process a callback URL, if we are being redirected from the OAuth provider if (Request.QueryString["oauthCallback"] == "true" && !IsPostBack) { AuthorizationServiceViewControllerBase.HandleCallback(); } List<ProviderHelperItem> items = new List<ProviderHelperItem>(); IUserService userService = ApplicationContext.Current.Services.Get<IUserService>(); IList<IOAuthProvider> providerList = EntityFactory.GetRepository<IOAuthProvider>().FindAll(); IList<IUserOAuthToken> tokenList = EntityFactory.GetRepository<IUserOAuthToken>().FindByProperty("User.Id", userService.UserId.Trim()); foreach (IOAuthProvider provider in providerList) { if (UserHasAccess(provider.ProviderKey)) { ProviderHelperItem item = new ProviderHelperItem(provider); foreach (IUserOAuthToken token in tokenList) { if (token.OAuthProvider.Id == provider.Id) { item.AccountName = token.AccountLoginName; item.IsAuthorized = true; } } items.Add(item); } } lblNoProviders.Visible = items.Count == 0; providerListView.DataSource = items; providerListView.DataBind(); }