asp.net-identity-2

ASP.NET Identity 2 Remember Me - User Is Being Logged Out

隐身守侯 提交于 2019-12-03 06:23:20
I am using Identity 2.1 in my MVC5 app. I am setting the isPersistent property of the PasswordSignInAsync to true to enable 'Remember Me': var result = await SignInManager.PasswordSignInAsync(model.Username, model.Password, true, shouldLockout: false); But if I stay logged in overnight, then when I refresh the page in the morning, it logs me out and I have to sign in again. How do I prevent automatic logging out until the user manually logs out? Is it something to do with the Cookie Authentication that identity uses? I don't really understand the CookieAuthenticationOptions that are set in

asp.net identity 2.0 unity not resolving default user store

我与影子孤独终老i 提交于 2019-12-03 06:15:10
问题 i get the following exception when trying to configure Unity using Unity.Mvc5 with an MVC 5 application using Identity 2.0 and the Identity 2.0 Samples boilerplate. i have read this SO Configure Unity DI for ASP.NET Identity and i'm still not clear on what i'm missing. What am i doing wrong here? The current type, System.Data.Common.DbConnection, is an abstract class and cannot be constructed. Are you missing a type mapping? [ResolutionFailedException: Resolution of the dependency failed,

Custom ASP.NET Identity 2.0 UserStore - Is implementing all interfaces required?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 04:57:28
I've created a custom IUserStore<TUser,int> for my application. I've implemented the interfaces I need, IUserStore<TUser, int>, IUserRoleStore<TUser, int>, IUserLockoutStore<TUser, int>, IUserPasswordStore<TUser, int> but when I call var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); I get an exception saying Store does not implement IUserTwoFactorStore<TUser>. I'm not using two factor authentication anywhere in my application. Why does it expect me to implement that interface? Is it required that I implement all of

Dynamically assign controller action permissions to roles in asp.net MVC

岁酱吖の 提交于 2019-12-03 03:41:49
I am working on asp.net mvc 5. I want to assign permissions of controllers' action methods to roles dynamically without hard conding the roles in Authorize attribute. Here is the scenario - In my project, I have four roles - Student, Teacher, Program Officer and Admin. I want that admin can change the accessability of each role whenever he wishes. I do not want to hard code the authorize attribute with role names before every action name of controller because admin will not then be able to change the permissions of each role. I want to create a page where every action method of controller will

Get list of users with assigned roles in asp.net identity 2.0

こ雲淡風輕ζ 提交于 2019-12-03 03:38:09
问题 I have a drop down list box which lists roles. I want to get the list of users having that role. I mean list of users that are in "Administrator" role or "CanEdit" role. Here is my code: public IQueryable<Microsoft.AspNet.Identity.EntityFramework.IdentityUser> GetRolesToUsers([Control] string ddlRole) { //ddlRole returns role Id, based on this Id I want to list users var _db = new ApplicationDbContext(); IQueryable<Microsoft.AspNet.Identity.EntityFramework.IdentityUser> query = _db.Users; if

How to disable a User in Identity 2.0?

十年热恋 提交于 2019-12-03 03:24:11
I'm trying to find a way to disable a user in Identity 2.0 and can't seem to find any info on it. I would like to basically set a user to IsActive=false and would prefer to do it as soon as the user is created. However, I need a way to set the IsActive for our site Admin. I already have this with ASP.Net membership but I'm looking to covert the site to MVC and Identity. For my requirements we ask people to go ahead and register an account but we want it to be disabled by default. Then when we receive payment for joining we will go back and enable them. We also use it to disable users when

One to many relationship between AspNetUsers (Identity) and a custom table

蹲街弑〆低调 提交于 2019-12-03 03:09:46
I'm desperate trying to create an One to Many relationship between AspNetUsers table of Identity 2.0 and a custom table called Map (One user can have many maps, but a map can only have one user) I've tryied mostly every solutions available in this website and also lost many days trying other soulutions found in the web. I'm stuck. Nothing seems to work for me. I'm new to MVC and EF so basically I think I need some sort of step-by-step guide. Can anyone please be very kind to provide me a newbie guide to achieve this from a fresh made MVC5 Project. Thanks and sorry for the redundad question I

Get ASP.NET Identity Current User In View

三世轮回 提交于 2019-12-03 02:13:16
I use ASP.NET Identity 2.0 and MVC. I need to logged user's name,surname,email etc.. in view. How can get it? I can get just @User.Identity but there no my user class's property. //in my view, i need here my ApplicationUser class <div> @User.Identity.Name </div> //ApplicationUser class public class ApplicationUser : IdentityUser<int, CustomUserLogin, CustomUserRole, CustomUserClaim> { public ApplicationUser() { this.CreatedDate = DateTime.Now; } public DateTime CreatedDate { get; set; } public string Name { get; set; } public string Surname { get; set; } public string TaxOffice { get; set; } }

How do I extend IdentityRole using Web API 2 + AspNet Identity 2

怎甘沉沦 提交于 2019-12-03 00:44:04
I am attempting to extend the AspNet IdentityRole class provided in the Web API 2 (With Individual Accounts) template in the latest version of Visual Studio 2013. When I hit /api/roles it returns an empty array Identity Models namespace API.Models { // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more. public class ApplicationUser : IdentityUser<string, IdentityUserLogin, ApplicationUserRole, IdentityUserClaim>, IUser, IUser<string> { [NotMapped] public virtual UserProfile

Url Authorization with MVC and ASP.NET Identity

可紊 提交于 2019-12-03 00:31:23
I want to secure specific folders and resources in my application that are outside of the routes for my mvc application. I want these resources to only be available to authenticated users ( which role is not of concequence as long as they are authenticated ). Initially it seemed that the UrlAuthorizationModule would be the answer. I followed this article, Understanding IIS 7.0 URL Authorization , and I can get the module to work in the sense that it responds to the configuration elements in the web.config . My current problem is that I think it is enacting the rules based on the anonymous user