public void Create(InstallModel model)
        {
            var user = new User
            {
                Email    = model.AdminEmail,
                IsActive = true
            };

            _passwordManagementService.SetPassword(user, model.AdminPassword, model.ConfirmPassword);

            _userManagementService.AddUser(user);
            CurrentRequestData.CurrentUser = user;

            var adminUserRole = new UserRole
            {
                Name = UserRole.Administrator
            };

            user.Roles = new HashSet <UserRole> {
                adminUserRole
            };
            adminUserRole.Users = new HashSet <User> {
                user
            };

            _roleService.SaveRole(adminUserRole);
            _authorisationService.Logout();
            _authorisationService.SetAuthCookie(user, true);
        }
示例#2
0
 public RedirectResult Logout()
 {
     _authorisationService.Logout();
     return(Redirect("~"));
 }