Exemplo n.º 1
0
 private async Task SignInAsync(ApplicationUser user, bool isPersistent)
 {
     this.authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     this.authenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent },
                 await user.GenerateUserIdentityAsync(this.userManager, isPersistent));
 }
Exemplo n.º 2
0
        public ActionResult CreateUser(UserViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName = viewModel.Username,
                    Email = viewModel.Email,
                };

                var password = PasswordGenerator.GeneratePassword();
                var result = this.userManager.Create(user, password);
                if (result.Succeeded)
                {
                    var roleResult = this.userManager.AddToRoles(user.Id, Role.GameDesigner);
                    if (roleResult.Succeeded)
                    {
                        this.SendEmailConfirmation(user.Id, user.UserName, password);
                        return Redirect(UrlProvider<AccountController>.GetUrl(c => c.ManageUsers()));
                    }
                }
            }
            return View(viewModel);
        }