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; }
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>(); }
public AccountController( ApplicationUserManager userManager, ApplicationSignInManager signInManager) { this.UserManager = userManager; this.SignInManager = signInManager; }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager ) { UserManager = userManager; UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager) { AllowOnlyAlphanumericUserNames = false }; SignInManager = signInManager; }
public ManageUsersController(ApplicationDbContext context, ApplicationUserManager userManager, IEmailService emailService, ICurrentUser currentUser) { _context = context; _userManager = userManager; _emailService = emailService; _currentUser = currentUser; }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, IPlayerService service) { UserManager = userManager; SignInManager = signInManager; this.playerService = service; }
public ProjectsController(IProjectService projectService, IDictionaryService dictionaryService, ISprintService spirntService, ApplicationUserManager applicationUserManager) { _projectService = projectService; _dictionaryService = dictionaryService; _sprintService = spirntService; _applicationUserManager = applicationUserManager; }
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; }
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()); }
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("-----------"); }
public bool CreateUser(ApplicationUser user, string password) { var um = new ApplicationUserManager( new UserStore<ApplicationUser>(context)); var idResult = um.Create(user, password); return idResult.Succeeded; }
public bool AddUserToRole(string userId, string roleName) { var um = new ApplicationUserManager( new UserStore<ApplicationUser>(context)); var idResult = um.AddToRole(userId, roleName); return idResult.Succeeded; }
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())); }
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()); }
public UserController(ApplicationUserManager userManager, IThemeService themeService, IUserService userService, ISchoolService schoolService) { UserManager = userManager; _themeService = themeService; _userService = userService; _schoolService = schoolService; }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ILogAppService logAppService, IPrestadorAppService prestadorAppService) { _userManager = userManager; _signInManager = signInManager; _logAppService = logAppService; _prestadorAppService = prestadorAppService; }
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; }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager ) { sendMail = new SendMail(); UserManager = userManager; SignInManager = signInManager; usService = new UserService(); }
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); }
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); }
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); }
public StatisticsController() { db = new ApplicationDbContext(); userStore = new UserStore<ApplicationUser>(db); userManager = new ApplicationUserManager(userStore); statisticsService = new StatisticsService(db); }
public UserService() { _userManager = _userManager ?? new ApplicationUserManager(new UserStore<ApplicationUserEntity>()); _userRepository = _userRepository ?? new UserRepository<ApplicationUserEntity>(); UserMappingConfig.RegisterMappings(); }
public PartialViewResult filterReset() { return(PartialView("_ListUserTable", ApplicationUserManager.GetUsers())); }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ApplicationRoleManager roleManager) { UserManager = userManager; SignInManager = signInManager; RoleManager = roleManager; }
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())); }
public ActionResult UserEdit(UserViewModel user) { ApplicationUserManager.UpdateUser(user); return(RedirectToAction("UserDetails", new RouteValueDictionary(new { id = user.Id }))); }
public PartialViewResult DeleteUserReturnPartialView(int userId) { ApplicationUserManager.DeleteUser(userId); return(this.filterReset()); }
public PartialViewResult AddUser2RoleReturnPartialView(int id, int userId) { ApplicationUserManager.AddUser2Role(userId, id); return(PartialView("_ListUsersTable4Role", ApplicationRoleManager.GetRole(id))); }
public ActionResult DeleteUserRole(int id, int userId) { ApplicationUserManager.RemoveUser4Role(userId, id); return(RedirectToAction("Details", "USER", new { id = userId })); }
public AccountController(ApplicationUserManager userManager, ISecureDataFormat <AuthenticationTicket> accessTokenFormat) { UserManager = userManager; AccessTokenFormat = accessTokenFormat; }
// GET: Admin public ActionResult Index() { return(View(ApplicationUserManager.GetUsers())); }
public AccountController(ApplicationUserManager userManager) { _userManager = userManager; }
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>(); }
internal Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager userManager) { throw new NotImplementedException(); }
public Task <ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager) { return(Task.FromResult(GenerateUserIdentity(manager))); }
//called in BaseApiController public ModelFactory(HttpRequestMessage request, ApplicationUserManager appUserManager) { _UrlHelper = new UrlHelper(request); _AppUserManager = appUserManager; }
public ManageController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ApplicationDbContext applicationDbContext) { UserManager = userManager; SignInManager = signInManager; DbContext = _applicationDbContext; }
public bool AddUserToRole(ApplicationUserManager _userManager, string userId, string roleName) { var idResult = _userManager.AddToRole(userId, roleName); return(idResult.Succeeded); }
public UnitOfWork(string connectionString) { db = new ApplicationDbContext(connectionString); userManager = new ApplicationUserManager(new UserStore <ApplicationUser>(db)); playerManager = new PlayerManager(db); }