本文整理汇总了C#中ApplicationUserManager类的典型用法代码示例。如果您正苦于以下问题:C# ApplicationUserManager类的具体用法?C# ApplicationUserManager怎么用?C# ApplicationUserManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationUserManager类属于命名空间,在下文中一共展示了ApplicationUserManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StatisticsController
public StatisticsController()
{
db = new ApplicationDbContext();
userStore = new UserStore<ApplicationUser>(db);
userManager = new ApplicationUserManager(userStore);
statisticsService = new StatisticsService(db);
}
示例2: ManageUsersController
public ManageUsersController(ApplicationDbContext context, ApplicationUserManager userManager, IEmailService emailService, ICurrentUser currentUser)
{
_context = context;
_userManager = userManager;
_emailService = emailService;
_currentUser = currentUser;
}
示例3: AccountController
public AccountController(
ApplicationUserManager userManager,
ApplicationSignInManager signInManager)
{
this.UserManager = userManager;
this.SignInManager = signInManager;
}
示例4: GetClaims
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;
}
示例5: RegenerateIdentityCallback
/// <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;
}
示例6: AddUserToRole
public bool AddUserToRole(string userId, string roleName)
{
var um = new ApplicationUserManager(
new UserStore<ApplicationUser>(context));
var idResult = um.AddToRole(userId, roleName);
return idResult.Succeeded;
}
示例7: Application_Start
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 = "tanaka" }, "[email protected]");
await userManager.AddToRoleAsync(
(await userManager.FindByNameAsync("tanaka")).Id,
"users");
// 管理者の作成
await userManager.CreateAsync(new ApplicationUser { UserName = "super_tanaka" }, "[email protected]");
await userManager.AddToRoleAsync(
(await userManager.FindByNameAsync("super_tanaka")).Id,
"users");
await userManager.AddToRoleAsync(
(await userManager.FindByNameAsync("super_tanaka")).Id,
"admin");
Debug.WriteLine("-----------");
}
示例8: AccountController
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
{
sendMail = new SendMail();
UserManager = userManager;
SignInManager = signInManager;
usService = new UserService();
}
示例9: IdentityModelHelper
public IdentityModelHelper(ApplicationUserManager userManager, ApplicationRoleManager roleManager)
{
Contract.Assert(null != userManager);
Contract.Assert(null != roleManager);
_userManager = userManager;
_roleManager = roleManager;
}
示例10: AccountController
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager,
ApplicationRoleManager roleManager)
{
UserManager = userManager;
SignInManager = signInManager;
RoleManager = roleManager;
}
示例11: ManageController
public ManageController(ApplicationSignInManager signinManager, ApplicationUserManager appUserManager, IAuthenticationManager authenticationManager)
: base(appUserManager)
{
AuthenticationManager = authenticationManager;
UserManager = appUserManager;
SignInManager = signinManager;
}
示例12: AccountController
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, LmsUserManager lmsUserManager)
{
UserManager = userManager;
SignInManager = signInManager;
_lmsUserManager = lmsUserManager;
}
示例13: CreateAccount
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);
}
示例14: IdentityUnitOfWork
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);
}
示例15: TestWeekMenuController
public TestWeekMenuController()
{
_unitOfWork = new UnitOfWork(new ApplicationDbContext());
_db = _unitOfWork.GetContext();
_weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
_userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext()));
}