Esempio n. 1
0
        public async Task <UserManagerResult> FindAccountAndGetClaimAsync(
            string login,
            string password,
            string applicationCookie)
        {
            var identityUser = await FindAsync(login, password);

            if (identityUser == null)
            {
                return(UserManagerResult.Fail("Неверный логин или пароль."));
            }

            var claim = await CreateIdentityAsync(identityUser, applicationCookie);

            return(UserManagerResult.Success(claim));
        }
Esempio n. 2
0
        public async Task <UserManagerResult> CreateAccountAndGetClaimAsync(
            Account account,
            string password,
            string applicationCookie)
        {
            var identityUser = new AppIdentityUser {
                UserName = account.UserName
            };
            var result = await CreateAsync(identityUser, password);

            if (result.Succeeded)
            {
                await AddToRoleAsync(identityUser.Id, RoleNames.Expert);

                var claim = await CreateIdentityAsync(identityUser, applicationCookie);

                return(UserManagerResult.Success(claim));
            }

            return(UserManagerResult.Fail(result.Errors));
        }