Пример #1
5
        public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, LmsUserManager lmsUserManager)
        {
            UserManager = userManager;
            SignInManager = signInManager;
            _lmsUserManager = lmsUserManager;

        }
 /// <summary>
 /// Regenerates the identity callback function for cookie configuration (above).
 /// </summary>
 /// <param name="applicationUserManager">The application user manager.</param>
 /// <param name="applicationUser">The application user.</param>
 private static async Task<ClaimsIdentity> RegenerateIdentityCallback(ApplicationUserManager applicationUserManager, ApplicationUser applicationUser)
 {
     // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
     var userIdentity = await applicationUserManager.CreateIdentityAsync(applicationUser, DefaultAuthenticationTypes.ApplicationCookie);
     // Add custom user claims here
     return userIdentity;
 }
Пример #3
0
        public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManage, IUsersService usersService)
           : this(usersService)
        {
            this.UserManager = userManager;
            this.SignInManager = signInManager;

        }
 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager,
     ApplicationRoleManager roleManager)
 {
     UserManager = userManager;
     SignInManager = signInManager;
     RoleManager = roleManager;
 }
        //
        // GET: /Account/Login
        public AccountController(IServices services, ISettings settings, IComponents components, IUserStore<ApplicationUser, Guid> userStore)
            : base(services, settings)
        {
            _userManager = new ApplicationUserManager(userStore, services, components);

            Mapper.CreateMap<ApplicationUser, UserDto>();
        }
Пример #6
0
 public AccountController(
     ApplicationUserManager userManager,
     ApplicationSignInManager signInManager)
 {
     this.UserManager = userManager;
     this.SignInManager = signInManager;
 }
Пример #7
0
     public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
     {
         UserManager = userManager;
         UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager) { AllowOnlyAlphanumericUserNames = false };
 
         SignInManager = signInManager;
     }
Пример #8
0
 public ManageUsersController(ApplicationDbContext context, ApplicationUserManager userManager, IEmailService emailService, ICurrentUser currentUser)
 {
     _context = context;
     _userManager = userManager;
     _emailService = emailService;
     _currentUser = currentUser;
 }
Пример #9
0
        public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IPlayerService service)
        {
            UserManager = userManager;
            SignInManager = signInManager;

            this.playerService = service;
        }
Пример #10
0
 public ProjectsController(IProjectService projectService, IDictionaryService dictionaryService, ISprintService spirntService, ApplicationUserManager applicationUserManager)
 {
     _projectService = projectService;
     _dictionaryService = dictionaryService;
     _sprintService = spirntService;
     _applicationUserManager = applicationUserManager;
 }
Пример #11
0
 public ManageController(ApplicationSignInManager signinManager, ApplicationUserManager appUserManager, IAuthenticationManager authenticationManager)
     : base(appUserManager)
 {
     AuthenticationManager = authenticationManager;
     UserManager = appUserManager;
     SignInManager = signinManager;
 }
        public async static Task<IEnumerable<Claim>> GetClaims(ClaimsIdentity user)
        {
            List<Claim> claims = new List<Claim>();
            using (edisDbEntities db = new edisDbEntities())
            {
                if (user.HasClaim(c => c.Type == ClaimTypes.Role && c.Value == AuthorizationRoles.Role_Client))
                {

                    var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    var userProfile = await userManager.FindByNameAsync(user.Name);

                    var client = db.Clients.FirstOrDefault(c => c.ClientUserID == userProfile.Id);
                    if (client != null)
                    {
                        var clientGroup = db.ClientGroups.FirstOrDefault(c => c.ClientGroupID == client.ClientGroupID);
                        if (clientGroup != null && clientGroup.MainClientID == client.ClientUserID)
                        {
                            claims.Add(CreateClaim(ClaimType_ClientGroupLeader, ClaimValue_ClientGroupLeader_Leader));
                        }
                        else
                        {
                            claims.Add(CreateClaim(ClaimType_ClientGroupLeader, ClaimValue_ClientGroupLeader_Member));
                        }
                    }
                }
            }
            return claims;
        }
Пример #13
0
        public void TestRegister()
        {
            //http://blogs.interknowlogy.com/2014/08/21/mvc-series-part-2-accountcontroller-testing/
            Mock<IEmailer> EmailerMock = new Mock<IEmailer>();
            Mock<IUserStore<ApplicationUser>> userStoreMock = new Mock<IUserStore<ApplicationUser>>();
            ApplicationUserManager userManager = new ApplicationUserManager(userStoreMock.Object);
            //IAuthenticationManager authManager = AuthenticationManager.
            Mock< IAuthenticationManager> authMock = new Mock<IAuthenticationManager>();
            ApplicationSignInManager manager = new ApplicationSignInManager(userManager, authMock.Object);

            AccountController Controller = new AccountController(userManager, manager, EmailerMock.Object);
            Mock<AccountController> ControllerMock = new Mock<AccountController>(EmailerMock.Object);

            Mock<ApplicationUserManager> UserManagerMock = new Mock<ApplicationUserManager>();
            Mock<ApplicationSignInManager> AppSignInManagerMock = new Mock<ApplicationSignInManager>();

            RegisterViewModel vm = new RegisterViewModel()
            {
                UserName    = "******",
                Email = "*****@*****.**",

                UserRole = "Teacher"
            };

            var result = Controller.Register(vm).Result;

            EmailerMock.Verify(a => a.Send());
        }
Пример #14
0
        protected async void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // ユーザーとロールの初期化
            // ロールの作成
            var roleManager = new ApplicationRoleManager(new UserStore());
            await roleManager.CreateAsync(new ApplicationRole { Name = "admin" });
            await roleManager.CreateAsync(new ApplicationRole { Name = "users" });

            var userManager = new ApplicationUserManager(new UserStore());
            // 一般ユーザーの作成
            await userManager.CreateAsync(new ApplicationUser { UserName = "******" }, "p@ssw0rd");
            await userManager.AddToRoleAsync(
                (await userManager.FindByNameAsync("tanaka")).Id,
                "users");
            // 管理者の作成
            await userManager.CreateAsync(new ApplicationUser { UserName = "******" }, "p@ssw0rd");
            await userManager.AddToRoleAsync(
                (await userManager.FindByNameAsync("super_tanaka")).Id,
                "users");
            await userManager.AddToRoleAsync(
                (await userManager.FindByNameAsync("super_tanaka")).Id,
                "admin");

            Debug.WriteLine("-----------");
        }
Пример #15
0
 public bool CreateUser(ApplicationUser user, string password)
 {
     var um = new ApplicationUserManager(
         new UserStore<ApplicationUser>(context));
     var idResult = um.Create(user, password);
     return idResult.Succeeded;
 }
Пример #16
0
 public bool AddUserToRole(string userId, string roleName)
 {
     var um = new ApplicationUserManager(
         new UserStore<ApplicationUser>(context));
     var idResult = um.AddToRole(userId, roleName);
     return idResult.Succeeded;
 }
Пример #17
0
 public AccountController(
     ApplicationUserManager userManager,
     ISecureDataFormat<AuthenticationTicket> accessTokenFormat)
 {
     this.UserManager = userManager;
     this.AccessTokenFormat = accessTokenFormat;
 }
 public TestWeekMenuController()
 {
     _unitOfWork = new UnitOfWork(new ApplicationDbContext());
     _db = _unitOfWork.GetContext();
     _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
     _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext()));
 }
Пример #19
0
        public BlogController(IBlogRepository blogRepository, ApplicationUserManager userManager, ApplicationSignInManager signInManager)
        {
            _blogRepository = blogRepository;
            UserManager = userManager;
            SignInManager = signInManager;

        }
        public void ConfigureOAuth(IAppBuilder app, HttpConfiguration config)
        {
            UserManagerFactory = () =>
            {
                try
                {
                    var userRepository = config.DependencyResolver.GetService(typeof(IUserRepository));
                    var userManager =
                        new ApplicationUserManager(userRepository as IUserRepository);
                    return userManager;
                }
                catch (Exception)
                {
                    return null;
                }
            };

            app.CreatePerOwinContext(UserManagerFactory);

            var oAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
                Provider = new SimpleAuthorizationProvider()
            };

            app.UseOAuthAuthorizationServer(oAuthServerOptions);

            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
Пример #21
0
		public UserController(ApplicationUserManager userManager, IThemeService themeService, IUserService userService, ISchoolService schoolService)
		{
			UserManager = userManager;
			_themeService = themeService;
			_userService = userService;
			_schoolService = schoolService;
		}
Пример #22
0
 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ILogAppService logAppService, IPrestadorAppService prestadorAppService)
 {
     _userManager = userManager;
     _signInManager = signInManager;
     _logAppService = logAppService;
     _prestadorAppService = prestadorAppService;
 }
Пример #23
0
 public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)
 {
     // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
     var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
     // Add custom user claims here
     return userIdentity;
 }
Пример #24
0
 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
 {
     sendMail = new SendMail();
     UserManager = userManager;
     SignInManager = signInManager;
     usService = new UserService();
 }
Пример #25
0
 public IdentityModelHelper(ApplicationUserManager userManager, ApplicationRoleManager roleManager)
 {
     Contract.Assert(null != userManager);
     Contract.Assert(null != roleManager);
     _userManager = userManager;
     _roleManager = roleManager;
 }
 public static void SignIn(ApplicationUserManager manager, AppUser user, bool isPersistent)
 {
     IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
     authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     var identity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
     authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
 }
Пример #27
0
        public ActionResult CreateAccount(NewUserModel model)
        {
            if (ModelState.IsValid)
            {
                ApplicationUserManager um = new ApplicationUserManager(new ApplicationUserStore(new ApplicationDbContext()));
                var pass = StringHelper.RandomString(8, 10);
                var user = new ApplicationUser()
                {
                    Id = Guid.NewGuid().ToString(),
                    UserName = model.UserName,
                    Email = model.Email,
                    Created = DateTime.Now,
                    LastLogin = null
                };
                var result = um.Create(user, pass);
                if(result.Succeeded)
                {
                    MailHelper.WelcomeSendPassword(user.UserName, user.Email, pass);
                    return RedirectToAction("Index", "People");
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                }
            }

            return View(model);
        }
Пример #28
0
 public IdentityUnitOfWork(string connectionString)
 {
     db = new StoreContext(connectionString);
     UserManager = new ApplicationUserManager(new UserStore<ApplicationUser>(db));
     RoleManager = new ApplicationRoleManager(new RoleStore<ApplicationRole>(db));
     ClientManager = new ClientManager(db);
 }
Пример #29
0
 public StatisticsController()
 {
     db = new ApplicationDbContext();
     userStore = new UserStore<ApplicationUser>(db);
     userManager = new ApplicationUserManager(userStore);
     statisticsService = new StatisticsService(db);
 }
Пример #30
0
        public UserService()
        {
            _userManager = _userManager ?? new ApplicationUserManager(new UserStore<ApplicationUserEntity>());
            _userRepository = _userRepository ?? new UserRepository<ApplicationUserEntity>();

            UserMappingConfig.RegisterMappings();
        }
Пример #31
0
 public PartialViewResult filterReset()
 {
     return(PartialView("_ListUserTable", ApplicationUserManager.GetUsers()));
 }
Пример #32
0
 public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ApplicationRoleManager roleManager)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
     RoleManager   = roleManager;
 }
Пример #33
0
 public void RemoveFromRole(ApplicationUserManager userManager, string userId, string roleName)
 {
     userManager.RemoveFromRole(userId, roleName);
 }
 public ManageController(ApplicationUserManager userManager, ApplicationSignInManager signInManager)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
 }
 private bool HasPassword(ApplicationUserManager manager)
 {
     return(manager.HasPassword(User.Identity.GetUserId()));
 }
Пример #36
0
 public ActionResult UserEdit(UserViewModel user)
 {
     ApplicationUserManager.UpdateUser(user);
     return(RedirectToAction("UserDetails", new RouteValueDictionary(new { id = user.Id })));
 }
Пример #37
0
 public PartialViewResult DeleteUserReturnPartialView(int userId)
 {
     ApplicationUserManager.DeleteUser(userId);
     return(this.filterReset());
 }
Пример #38
0
 public PartialViewResult AddUser2RoleReturnPartialView(int id, int userId)
 {
     ApplicationUserManager.AddUser2Role(userId, id);
     return(PartialView("_ListUsersTable4Role", ApplicationRoleManager.GetRole(id)));
 }
Пример #39
0
 public ActionResult DeleteUserRole(int id, int userId)
 {
     ApplicationUserManager.RemoveUser4Role(userId, id);
     return(RedirectToAction("Details", "USER", new { id = userId }));
 }
Пример #40
0
 public AccountController(ApplicationUserManager userManager,
                          ISecureDataFormat <AuthenticationTicket> accessTokenFormat)
 {
     UserManager       = userManager;
     AccessTokenFormat = accessTokenFormat;
 }
Пример #41
0
 // GET: Admin
 public ActionResult Index()
 {
     return(View(ApplicationUserManager.GetUsers()));
 }
Пример #42
0
 public AccountController(ApplicationUserManager userManager)
 {
     _userManager = userManager;
 }
Пример #43
0
 public PartialViewResult DeleteUserFromRoleReturnPartialView(int id, int userId)
 {
     ApplicationUserManager.RemoveUser4Role(userId, id);
     return(PartialView("_ListUsersTable4Role", ApplicationRoleManager.GetRole(id)));
 }
 public ManageController(ApplicationUserManager userManager)
 {
     UserManager = userManager;
 }
 public TwoFactorAuthenticationSignIn()
 {
     manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
     signinManager = Context.GetOwinContext().GetUserManager <ApplicationSignInManager>();
 }
Пример #46
0
 internal Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager userManager)
 {
     throw new NotImplementedException();
 }
Пример #47
0
 public Task <ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
 {
     return(Task.FromResult(GenerateUserIdentity(manager)));
 }
Пример #48
0
 //called in BaseApiController
 public ModelFactory(HttpRequestMessage request, ApplicationUserManager appUserManager)
 {
     _UrlHelper = new UrlHelper(request);
     _AppUserManager = appUserManager;
 }
Пример #49
0
 public ManageController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ApplicationDbContext applicationDbContext)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
     DbContext     = _applicationDbContext;
 }
Пример #50
0
        public bool AddUserToRole(ApplicationUserManager _userManager, string userId, string roleName)
        {
            var idResult = _userManager.AddToRole(userId, roleName);

            return(idResult.Succeeded);
        }
Пример #51
0
 public UnitOfWork(string connectionString)
 {
     db            = new ApplicationDbContext(connectionString);
     userManager   = new ApplicationUserManager(new UserStore <ApplicationUser>(db));
     playerManager = new PlayerManager(db);
 }