Ejemplo n.º 1
0
        public async Task <User> FindByUserNameAndPasswordAsync(string userName, string password)
        {
            userName.ThrowIfNull("userName");
            password.ThrowIfNull("password");

            var identityUser = await _userManager.FindAsync(userName, password);

            var user = IdentityModelFactory.Create(identityUser);

            return(user);
        }
        public override async Task AuthenticateExternalAsync(ExternalAuthenticationContext ctx)
        {
            var externalUser = ctx.ExternalIdentity;
            var message      = ctx.SignInMessage;

            if (externalUser == null)
            {
                throw new ArgumentNullException("externalUser");
            }

            var user = await userManager.FindAsync(new Microsoft.AspNet.Identity.UserLoginInfo(externalUser.Provider, externalUser.ProviderId));

            if (user == null)
            {
                ctx.AuthenticateResult = await ProcessNewExternalAccountAsync(externalUser.Provider, externalUser.ProviderId, externalUser.Claims);
            }
            else
            {
                ctx.AuthenticateResult = await ProcessExistingExternalAccountAsync(user.Id, externalUser.Provider, externalUser.ProviderId, externalUser.Claims);
            }
        }
Ejemplo n.º 3
0
        public async Task <ApplicationUser> FindUser(string userName, string password)
        {
            ApplicationUser user = await _userManager.FindAsync(userName, password);

            return(user);
        }