asp.net-identity

Auto Logout from Asp.net Identity when user is Inactive

旧巷老猫 提交于 2019-12-13 03:41:02
问题 I am devoloping Asp.net mvc application with Asp.net Identity framework with a requirement of user should be autologout after 10 mins only when the user is inactive(With out mouse movement/Click).I have tried with code which works as user logsout even when the user is active in the application,Can any one help me out in accomplishing these ASAP.Response would be appreciated Please find my Starup.cs file code here: using System; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity

Identity dbcontext reference to another dbcontext

折月煮酒 提交于 2019-12-13 02:48:44
问题 I have two db contexts in my project. One for users based .Net core identity and another for products and orders etc. for a webshop. The scenario is that a user via .Net core identity can log in, add product to shopping cart and complete an order. Therefor a need to have a foreign key from the identity user dbcontext to the other dbcontext containing the orders and product tables. I would like to have the users and the products/orders in two seperate dbcontext. So my question is how to go

How should password be transfered for logon in Asp.net Identity

℡╲_俬逩灬. 提交于 2019-12-13 02:12:31
问题 We are using Asp.net Identity (currently version 2). For the purpose of local user authentication, the framework expects clear-text passwords. As far as I understand, this is not the safe method to transfer passwords. A quick answer can be: use ssl to encrypt password transfer, but this is not a viable solution to everyone. This is what we think: The logon form is provided with a one-time random token, then it hashes the password, attaches it to the token and hashes it again. The result is

assign multiple roles for a user in aspnet identity

时光怂恿深爱的人放手 提交于 2019-12-13 02:08:18
问题 I have requirement to add multiple user roles for a particular user in user creation phase. So I'm going to achieve this using checkboxes in front end so this the viewpage @model project_name.Models.RegisterViewModel @{ } @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal"})) { <div class="form-group"> <label class="col-md-2 control-label"> Select User Role </label> <div class="col-md-10"> @foreach (var item in (SelectList)ViewBag.RoleId) { <input

Database connection not created in IdentityDbContext

梦想与她 提交于 2019-12-13 02:04:04
问题 I'm trying to authentication Asp.Net Core 2 Web API with Asp.Net Identity 2. Here's my code for the AuthController and the databasecontext: public AuthController(UserManager<ApiUser> userManager, SignInManager<ApiUser> signInManager, RoleManager<ApiRole> roleManager , IPasswordHasher<ApiUser> passwordHasher, IConfiguration configurationRoot, ILogger<AuthController> logger) { _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _logger = logger;

There is already an object named 'AspNetUsers' in the database

陌路散爱 提交于 2019-12-13 02:02:55
问题 I have searched all over the internet, stack overflow but i am feeling lost in the mystery of Entity framework Migration. I have existing database. I have added three new tables which have some relation with AspNetUsers table. I have tried two ways to add these tables to database using pmc. first comment out all new tables in dbcontext and then use following command. Add-migration initial -ignorechanges then uncomment the tables from dbcontext and run update-database command. result no new

How to change table names in Asp.net Identity 3.0?

孤街浪徒 提交于 2019-12-13 01:12:04
问题 How to change table names in ASP.net Identity 3.0? I have searched but I didn't get any workable write up for Identity 3.0 and this How can I change the table names used by asp.net identity 3 (vnext)? is not working. 回答1: You can do this easily by changing the entity mapping with extension method ToTable("TableName") on OnModelCreating of your DbContext : protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity<User>().ToTable("Users"); //

How to implement a relationship between IdentityRole (dbo.AspNetRoles) and a custom entity?

我们两清 提交于 2019-12-12 23:30:34
问题 I'm working with a project similar to the MVC template project. I've created some models that I want to be represented in the database. I can create them with a DbContext class just fine, the issue is connecting my class's RoleId with ASP.Net Identity's Role table's id. Any ideas as to how this is possible? 回答1: Let's say that RoleDependent is your entity class. Then: 1) If you need one-to-many (1:N) relationship beetween RoleDependent and Role : public class RoleDependent { public Int32 Id {

AuthenticationManager.GetExternalLoginInfo returns null except in ExternalLoginCallback

空扰寡人 提交于 2019-12-12 21:51:54
问题 I am using the standard MVC template in VS2013 and have enabled external logins. It works fine, and I am now adding some features. I find that AuthenticationManager.GetExternalLoginInfo works fine in the ExternalLoginCallback action. However, if I have it anywhere else, it always returns null, even if the user is logged in. I did a test by adding the following in the Account controller: [Authorize] public async Task<ActionResult> Test() { Debug.Assert(User.Identity.IsAuthenticated); var

How to create a ClaimIdentity in asp.net 5

做~自己de王妃 提交于 2019-12-12 20:37:40
问题 In old asp.net identity 2.0, there is a CreateIdentityAsync() method in type Microsoft.AspNet.Identity.UserManager. But now asp.net 5 has removed this method, how can I create a ClaimsIdentity representing the user now? Thanks in advance. public virtual Task<ClaimsIdentity> CreateIdentityAsync(TUser user, string authenticationType); 回答1: Is this what you are looking for? http://aspnet-docs-example.readthedocs.org/en/latest/autoapi/Microsoft/AspNet/Identity/IUserClaimsPrincipalFactory-TUser/