asp.net-identity

ASP.NET Identity Extend methods to access user properties

偶尔善良 提交于 2019-12-04 02:18:04
As I can extend methods to access user properties? There are methods like: User.Identity.GetUserId() User.Identity.GetUserName() Which are accessible from the views and the controllers. I want to extend this functionality with methods like: User.Identity.GetUserPhoneNumber() User.Identity.GetUserLanguaje() Similar Question: Need access more user properties in User.Indentity answered by Microsoft professionals at codeplex worklog as below "You can get the User object and do User.Email or User.PhoneNumber since these properties are hanging off the User model" We can get the application current

What are a security token and security stamp in ASP.NET Identity?

流过昼夜 提交于 2019-12-04 01:31:01
I need background about two features of ASP.NET Identity please: Security token - What is it? is it a temporary password sent to the user's email? Security Stamp - Is it something else than security tokens? If yes, what's its purpose? how are they different? Thanks, ashilon Try to answer your questions in order: Tokens are used in Identity in several ways. You can use them to reset a password or confirm the email address of a user. Here you generate a token specific for the appropriate user which can be used for these two purposes. They will be send to the user, for example as a link to a view

How to get ApplicationDbContext out of the Owin pipeline

扶醉桌前 提交于 2019-12-04 01:05:53
This has to be simple, but I'm going bug-eyed trying to find the answer. How does a controller action get a reference to the per-request ApplicationDbContext that was stashed in the Owin pipeline? EDIT: Ok, I think I'm getting closer... or maybe not... All of my Googling seems to lead to this blog post , which sez to use: var dbContext = context.Get<ApplicationDbContext>(); where context is apparently an instance of Microsoft.Owin.IOwinContext . So I tried: var db = HttpContext.GetOwinContext().Get<ApplicationDbContext>(); But the Get<T> method requires a string key parameter. :( And the

ASP.NET Identity - Forcing a re-login with security stamp

前提是你 提交于 2019-12-04 00:31:53
问题 So from What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface? we learn that ASP.NET Identity has a security stamp feature that is used to invalidate a users login cookie, and force them to re-login. In my MVC app, it is possible for admins to archive users. When arched, they should immediately be logged out and forced to log in again (which would then reject them since they're archived). How can I do this? I understand that the security stamp is the key. The default setup looks

How to keep user login in to system and logout only after user clicks on logout button?

梦想与她 提交于 2019-12-04 00:11:46
I am using custom implementation of microsoft asp.net identity because i have custom tables that is why i have given custom implementation of all my methods IUserStore and IUserPasswordStore . Problem is when user logins then after 10 - 15 minutes login user session gets expired but what i want is unless user logs out i want to keep user login in to the system. Code: public partial class Startup { public void ConfigureAuth(IAppBuilder app) { app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app

Unable to add and fetch custom claims values

孤街醉人 提交于 2019-12-03 23:33:36
问题 I am using mvc 5 with identity 2.0. I want use custom claim values over the application but I get null value. What am I doing wrong? Updated code Login Code in account controller if (!string.IsNullOrEmpty(model.UserName) && !string.IsNullOrEmpty(model.Password)) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); var result = SignInManager.PasswordSignIn(model.UserName, model.Password, model.RememberMe, shouldLockout: false); //Generate verification token Dictionary

How to create a security stamp value for asp.net identity (IUserSecurityStampStore)

流过昼夜 提交于 2019-12-03 23:25:08
In my MVC-5 application, I have to create security stamp values manually . The current implementation of the identity team seems to use a guid. Guid.NewGuid().ToString("D") Is it safe to create a new Guid myself to use as a new security stamp value or will this lead to problems in future implementations of asp.net identity? Is there a method to let the identity framework create such a stamp-value for me so that my implementation is safe for future changes? Out of the documentation of the identity implementation for the entity-framework, it seems that it can be any random value: IdentityUser

No MediaTypeFormatter is available to read an object of type 'Advertisement' in asp.net web api

时光总嘲笑我的痴心妄想 提交于 2019-12-03 23:00:35
I have a class that name is Advertisement: public class Advertisement { public string Title { get; set; } public string Desc { get; set; } } and in my controller: public class OrderController : ApiController { public UserManager<IdentityUser> UserManager { get; private set; } // Post api/Order/Test [Route("Test")] public IHttpActionResult Test(Advertisement advertisement) { var currentUser = User.Identity.GetUserId(); Task<IdentityUser> user = UserManager.FindByIdAsync(currentUser); return Ok(User.Identity.GetUserId()); } but when I test it with Postman I face this error, "Message": "The

ASP.NET Core - custom AspNetCore.Identity implementation not working

北城余情 提交于 2019-12-03 21:06:14
问题 I'm building a completely custom AspNetCore.Identity Implementation because I want TKey to be System.Guid across the board. With respect, I have derived types for... Role : IdentityRole<Guid, UserRole, RoleClaim> RoleClaim : IdentityRoleClaim<Guid> User : IdentityUser<Guid, UserClaim, UserRole, UserLogin> UserClaim : IdentityUserClaim<Guid> UserLogin : IdentityUserLogin<Guid> UserRole : IdentityUserRole<Guid> UserToken : IdentityUserToken<Guid> ApplicationDbContext : IdentityDbContext<User,

Asp.net identity Google account id migration from openId to oauth

▼魔方 西西 提交于 2019-12-03 21:05:40
I have an existing asp.net mvc5 application using DotNetOpenAuth for Google OpenId authentication. I am migrating to Asp.Net Identity, and using Google+ Auth with OAuth2.0. But I have seen thant I can't map existing OpenId account Id to OAuth2.0 Id : - Old id is : https://www.google.com/accounts/o8/id?id=blablabla - New Id is : a long number Since I would like to use new id, I am searching for help on migrating identities. I have not found yet a simple sample to achieve this. I am using a new asp.net mvc5 application (freshly scaffolded), added Microsoft Identity (with custom implementation