• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Identity.UserLoginInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.AspNet.Identity.UserLoginInfo的典型用法代码示例。如果您正苦于以下问题:C# UserLoginInfo类的具体用法?C# UserLoginInfo怎么用?C# UserLoginInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UserLoginInfo类属于Microsoft.AspNet.Identity命名空间,在下文中一共展示了UserLoginInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddLogin

 public void AddLogin(IdentityUser user, UserLoginInfo login)
 {
     _db[_tables.UsersLogins].Insert(
         LoginProvider: login.LoginProvider,
         ProviderKey: login.ProviderKey,
         UserId: user.Id);
 }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:7,代码来源:UserLoginsTable.cs


示例2: RemoveLogin

 public void RemoveLogin(IdentityUser user, UserLoginInfo login)
 {
     _db[_tables.UsersLogins].Delete(
         UserId: user.Id,
         LoginProvider: login.LoginProvider,
         ProviderKey: login.ProviderKey);
 }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:7,代码来源:UserLoginsTable.cs


示例3: Handler_ReturnsNullRemoteMembership_WhenNotFound_ByUserId

        public void Handler_ReturnsNullRemoteMembership_WhenNotFound_ByUserId()
        {
            var userId = FakeData.Id();
            var otherUserId = FakeData.Id(userId);
            var loginProvider = FakeData.String();
            var providerKey = FakeData.String();
            var userLoginInfo = new UserLoginInfo(loginProvider, providerKey);
            var remoteMemberships = new[]
            {
                new ProxiedRemoteMembership(loginProvider, providerKey)
                    { UserId = otherUserId, },
                new ProxiedRemoteMembership(FakeData.String(), FakeData.String())
                    { UserId = userId, },
            };
            var data = remoteMemberships.AsQueryable();
            var query = new RemoteMembershipByUser(userId, userLoginInfo);
            var dbSet = new Mock<DbSet<RemoteMembership>>(MockBehavior.Strict).SetupDataAsync(data);
            var entities = new Mock<IReadEntities>(MockBehavior.Strict);
            var entitySet = new EntitySet<RemoteMembership>(dbSet.Object, entities.Object);
            entities.Setup(x => x.Query<RemoteMembership>()).Returns(entitySet);
            var handler = new HandleRemoteMembershipByUserQuery(entities.Object);

            RemoteMembership result = handler.Handle(query).Result;

            result.ShouldBeNull();
            entities.Verify(x => x.Query<RemoteMembership>(), Times.Once);
        }
开发者ID:phobos04,项目名称:tripod,代码行数:27,代码来源:RemoteMembershipByUserTests.cs


示例4: Add_Should_Add_New_Login_Just_After_UserManager_CreateAsync_Get_Called

        public async Task Add_Should_Add_New_Login_Just_After_UserManager_CreateAsync_Get_Called()
        {
            const string userName = "Tugberk";
            const string loginProvider = "Twitter";
            const string providerKey = "12345678";

            using (IDocumentStore store = CreateEmbeddableStore())
            {
                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    RavenUserStore<RavenUser> userStore = new RavenUserStore<RavenUser>(ses);
                    UserManager<RavenUser> userManager = new UserManager<RavenUser>(userStore);

                    RavenUser user = new RavenUser(userName);
                    UserLoginInfo loginToAdd = new UserLoginInfo(loginProvider, providerKey);
                    await userManager.CreateAsync(user);
                    await userManager.AddLoginAsync(user.Id, loginToAdd);
                    await ses.SaveChangesAsync();
                }

                using (IAsyncDocumentSession ses = store.OpenAsyncSession())
                {
                    ses.Advanced.UseOptimisticConcurrency = true;
                    IUserLoginStore<RavenUser, string> userLoginStore = new RavenUserStore<RavenUser>(ses);
                    RavenUser user = await ses.LoadAsync<RavenUser>(RavenUser.GenerateKey(userName));
                    RavenUserLogin foundLogin = await ses.LoadAsync<RavenUserLogin>(RavenUserLogin.GenerateKey(loginProvider, providerKey));

                    // Assert
                    Assert.Equal(1, user.Logins.Count());
                    Assert.NotNull(foundLogin);
                }
            }
        }
开发者ID:andrewm1986,项目名称:AspNet.Identity.RavenDB,代码行数:34,代码来源:RavenUserLoginStoreFacts.cs


示例5: ByUserLoginInfoAsync

 public static Task<RemoteMembership> ByUserLoginInfoAsync(this IQueryable<RemoteMembership> set,
     UserLoginInfo userLoginInfo, bool allowNull = true)
 {
     return allowNull
         ? set.SingleOrDefaultAsync(ByUserLoginInfo(userLoginInfo))
         : set.SingleAsync(ByUserLoginInfo(userLoginInfo));
 }
开发者ID:phobos04,项目名称:tripod,代码行数:7,代码来源:QueryRemoteMemberships.cs


示例6: AccountController

        public AccountController()
            : this(new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext())))
        {
            var rm = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));
            try
            {
                if (!rm.RoleExists("admin"))
                {
                    rm.Create(new IdentityRole("admin"));
                    var um = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    var user = new ApplicationUser() { UserName = "adminn" };
                    um.Create(user, "asdfgh");
                    UserLoginInfo info = new UserLoginInfo("Google",
                            "https://www.google.com/accounts/o8/id?id=AItOawka6ZSrKNn7UY3ZUcjFRZMSLhMqQNKArWQ");
                    um.AddToRole(user.Id, "admin");
                    um.AddLogin(user.Id, info);

                }
            }
            catch (TimeoutException)
            {
                //CreateAdmin();

            }
        }
开发者ID:Baptista,项目名称:PS,代码行数:25,代码来源:AccountController.cs


示例7: AzureLogin

 public AzureLogin(string ownerId, UserLoginInfo info)
     : this()
 {
     UserId = ownerId;
     LoginProvider = info.LoginProvider;
     ProviderKey = info.ProviderKey;
 }
开发者ID:hjgraca,项目名称:azuretake,代码行数:7,代码来源:AzureLogin.cs


示例8: CreateUserWithSocialProvider

        public IdentityUser CreateUserWithSocialProvider(UserLoginInfo login, ClaimsIdentity identity)
        {
            var userProfile = _userProfileSocialService.GetFromSocialProvider(login.LoginProvider, identity);
            var user = new IdentityUser(GenerateUserName())
            {
                Email = userProfile.Email
            };

            var userCreationResult = _userManager.Create(user);
            if (userCreationResult.Succeeded)
            {
                var userLoginResult = _userManager.AddLogin(user.Id, login);
                if (!userLoginResult.Succeeded)
                {
                    foreach (var error in userLoginResult.Errors)
                    {
                        throw new Exception(error);
                    }
                }
            }
            else
            {
                foreach (var error in userCreationResult.Errors)
                {
                    throw new Exception(error);
                }
            }

            userProfile.UserId = user.Id;
            _userProfileRepository.Add(userProfile);
            _userProfileRepository.SaveChanges();

            return user;
        }
开发者ID:Willjobs94,项目名称:empleo-dot-net,代码行数:34,代码来源:AuthenticationService.cs


示例9: UserLogin

 /// <summary>
 /// Create a new UserLogin for the specified info and user
 /// </summary>
 /// <param name="loginInfo">Information about the login</param>
 /// <param name="userId">ID of the user the login is for</param>
 public UserLogin(UserLoginInfo loginInfo, string userId)
 {
     LoginProvider = loginInfo.LoginProvider;
     ProviderDisplayName = loginInfo.ProviderDisplayName;
     ProviderKey = loginInfo.ProviderKey;
     UserId = userId;
 }
开发者ID:danclarke,项目名称:AspNetIdentity3NPOCODataStores,代码行数:12,代码来源:UserLogin.cs


示例10: AreEqual

        public static bool AreEqual(this UserLoginInfo thisObj, UserLoginInfo obj)
        {
            if (thisObj == null && obj == null) return true; // both objects are null
            if (thisObj == null || obj == null) return false; // only one of the objects are null

            return thisObj.LoginProvider.Equals(obj.LoginProvider, StringComparison.OrdinalIgnoreCase) &&
                   thisObj.ProviderKey.Equals(obj.ProviderKey, StringComparison.OrdinalIgnoreCase);
        }
开发者ID:ghstahl,项目名称:vNext.Jan2016Web,代码行数:8,代码来源:UserLoginInfoExtensions.cs


示例11: WhenHaveNoUser

        public void WhenHaveNoUser()
        {
            var login = new UserLoginInfo("ProviderTest", "ProviderKey");
            var store = new UserStore<IdentityUser>(_session);
            var user = store.FindAsync(login).Result;

            Assert.IsNull(user);
        }
开发者ID:robocik,项目名称:NHibernate.AspNet.Identity,代码行数:8,代码来源:UserStoreTest.cs


示例12: Equal

		public static void Equal(UserLoginInfo expected, UserLoginInfo actual)
		{
			Assert.True((expected == null && actual == null) || (expected != null && actual != null));

			Assert.Equal(expected.LoginProvider, actual.LoginProvider);
			Assert.Equal(expected.ProviderKey, actual.ProviderKey);
			Assert.Equal(expected.ProviderDisplayName, actual.ProviderDisplayName);
		}
开发者ID:saan800,项目名称:SaanSoft.AspNet.Identity3.MongoDB,代码行数:8,代码来源:UserLoginInfoAssert.cs


示例13: CanAddLogin

        public void CanAddLogin()
        {
            var user = IdentityUserMother.EmptyUser();
            var login = new UserLoginInfo("test", "testing");

            user.AddLogin(login).ShouldBe(true);
            user.Logins.ShouldContain(login);
        }
开发者ID:rzakirov,项目名称:MongoIdentity,代码行数:8,代码来源:IdentityUserTests.cs


示例14: CanCheckIfLoginExists

        public void CanCheckIfLoginExists()
        {
            var user = IdentityUserMother.EmptyUser();
            var login = new UserLoginInfo("test", "testing");

            user.AddLogin(login).ShouldBe(true);
            user.HasLogin(login).ShouldBe(true);
        }
开发者ID:rzakirov,项目名称:MongoIdentity,代码行数:8,代码来源:IdentityUserTests.cs


示例15: Should_return_null_if_user_not_found

        public void Should_return_null_if_user_not_found()
        {
            var login = new UserLoginInfo("Yahoo", "ghi");
            var task = _target.FindAsync(login);
            task.Wait();

            Assert.That(task.Result, Is.Null);
        }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:8,代码来源:When_finding_login.cs


示例16: Should_return_user_for_login

        public void Should_return_user_for_login()
        {
            var login = new UserLoginInfo("Google", "123");
            var task = _target.FindAsync(login);
            task.Wait();

            Assert.That(task.Result.Id, Is.EqualTo(TestData.John_UserId));

        }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:9,代码来源:When_finding_login.cs


示例17: FindUserIdByLogin

        /// <summary>
        /// Return a userId given a user's login
        /// </summary>
        /// <param name="userLogin">The user's login info</param>
        /// <returns></returns>
        public string FindUserIdByLogin(UserLoginInfo userLogin)
        {
            string commandText = "Select UserId from UserLogins where LoginProvider = @loginProvider and ProviderKey = @providerKey";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("loginProvider", userLogin.LoginProvider);
            parameters.Add("providerKey", userLogin.ProviderKey);

            return _database.GetStrValue(commandText, parameters);
        }
开发者ID:LexaGal,项目名称:Plants,代码行数:14,代码来源:UserLoginsTable.cs


示例18: FindUserIdByLogin

        /// <summary>
        /// Return a user ID given a user's login.
        /// </summary>
        /// <param name="userLogin">The user's login info.</param>
        /// <returns></returns>
        public string FindUserIdByLogin(UserLoginInfo userLogin)
        {
            string commandText = "SELECT \"UserId\" FROM \"AspNetUserLogins\" WHERE \"LoginProvider\" = @loginProvider AND \"ProviderKey\" = @providerKey";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("loginProvider", userLogin.LoginProvider);
            parameters.Add("providerKey", userLogin.ProviderKey);

            return _database.GetStrValue(commandText, parameters);
        }
开发者ID:carlosso,项目名称:AspNet.Identity.PostgreSQL,代码行数:14,代码来源:UserLoginsTable.cs


示例19: FindUserIdByLogin

        /// <summary>
        /// Return a user ID given a user's login.
        /// </summary>
        /// <param name="userLogin">The user's login info.</param>
        /// <returns></returns>
        public string FindUserIdByLogin(UserLoginInfo userLogin)
        {
            string commandText = "SELECT "+fielduserID.Quoted()+" FROM "+fullTableName+" WHERE "+fieldLoginProvider.Quoted()+" = @loginProvider AND "+fieldProviderKey.Quoted()+" = @providerKey";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("loginProvider", userLogin.LoginProvider);
            parameters.Add("providerKey", userLogin.ProviderKey);

            return _database.GetStrValue(commandText, parameters);
        }
开发者ID:stringariSM,项目名称:AspNet.Identity.PostgreSQL,代码行数:14,代码来源:UserLoginsTable.cs


示例20: FindAsync

 public async Task<AbitInfoIdentityUser> FindAsync(UserLoginInfo loginInfo)
 {
     using (IdentityDbContext<AbitInfoIdentityUser> context = _identityProvider.Context)
     {
         UserManager<AbitInfoIdentityUser> userManager =
             _identityProvider.GetUserManager(context);
         AbitInfoIdentityUser user = await userManager.FindAsync(loginInfo);
         return user;
     }
 }
开发者ID:dude3133,项目名称:Abit-info,代码行数:10,代码来源:AuthService.cs



注:本文中的Microsoft.AspNet.Identity.UserLoginInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# EntityFramework.IdentityManager类代码示例发布时间:2022-05-26
下一篇:
C# Identity.IdentityResult类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap