asp.net-identity-2

Manually validating a password reset token in ASP.NET Identity

烂漫一生 提交于 2019-12-03 00:17:29
I would like to manually validate a password reset token in ASP.NET Identity 2.0. I'm trying to create my own version of UserManager.ResetPasswordAsync(string userId, string token, string newPassword) that takes and IdentityUser instead of userId like this: UserManager.ResetPasswordAsync(IdentityUser user, string token, string newPassword) Not sure if I am doing this right, but here I am attempting to validate the code that was emailed to the user in an earlier step. I have not modified the code/token that sends the email to the user and generates the code. I am assuming this is the correct

Understanding MVC-5 Identity

柔情痞子 提交于 2019-12-02 21:20:12
I created a new ASP.NET MVC-5 application with Individual User Accounts and then updated all the Nuget packages in the solution. Now I'm trying to follow some of the guidelines shown in some tutorials but I encountered some problems. The first one is that a class called ApplicationRoleManager which is being used throughout the application wasn't created (the ApplicationUserManager was created). The second problem is more about Entity-Framework : I've seen that for seeding the database with a user and role many people create a static constructor in the ApplicationDbContext class: static

ASP.NET MVC5 - Keeping Users in Oracle Database

被刻印的时光 ゝ 提交于 2019-12-02 21:05:56
Once creating a ASP.NET MVC5 project (with target framework is .NET 4.5.1 and the authentication type is Individual User Account ), so what is the most elegant way to configure the project so that it keeps the user, claims, roles etc. in an Oracle 12c database? I mean, how can I keep the authorization/authentication data in Oracle without deforming the automatically-generated MVC5 project structure. I guess changing the <defaultConnection> tag is not enough and there should be another Oracle implementation to replace Microsoft.AspNet.Identity.EntityFramework . It would be very helpful to

OWIN Bearer Token Authentication

廉价感情. 提交于 2019-12-02 20:51:26
I have some questions related to Bearer Token. In Owin you can protect a ticket Protect(ticket) like this: ClaimsIdentity identity = new ClaimsIdentity(Startup.OAuthServerOptions.AuthenticationType); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); Dictionary<string, string> properties = new Dictionary<string, string>(); properties.Add("UserId", user.Id); properties.Add("UserName", user.UserName); properties.Add("Role", "user"); AuthenticationProperties properties = new AuthenticationProperties(properties); AuthenticationTicket ticket = new AuthenticationTicket(identity,

Asp.Net Identity save user without email

帅比萌擦擦* 提交于 2019-12-02 17:33:38
I want to save user without email, like this: var user = new ApplicationUser { UserName = model.Name }; var result = await UserManager.CreateAsync(user); But I got error "Email cannot be null or empty". Is there any solution for this? Or it is impossible? trailmax Identity depends on email as a way to reset user password. However, ignoring email is not simple, but possible. You'll need to implement Microsoft.AspNet.Identity.IIdentityValidator interface that ignores the lack of email: namespace Microsoft.AspNet.Identity { /// <summary> /// Used to validate an item /// /// </summary> ///

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

眉间皱痕 提交于 2019-12-02 17:07:26
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 (ddlRole != null) { //query = query.Where(e => e.Claims == ddlRole.Value); ??????? } return query; }

Identity 2.0 with custom tables

牧云@^-^@ 提交于 2019-12-02 14:53:50
I'm new to ASP.NET identity and am still trying to get my head around how it all works. Unfortunately I've found many of the tutorials I've tried are for Identity 1.0, whereas I'm attempting to work with Identity 2.0. The biggest problem I am facing is something I thought would be simple, but has turned out not to be. What I'm trying to do is use an existing database with an existing user table. Currently all I can seem to do is get Identity to create it's own tables to store user data. I don't want to use Entity Framework, but I've had great difficulty separating Entity Framework from

ASP.NET Identity 2 - UserManager.ConfirmEmail Fails In Production

大城市里の小女人 提交于 2019-12-02 11:09:48
I've set up OWIN in an ASP.NET MVC app (including email confirmation). When an account is created I get an email containing a link to confirm my email. When I visit the link, I get the "Invalid Token" error. If I take that exact same link and instead change the domain to point at localhost while debugging the project, the email confirms just fine. The project is being deployed to an Azure Web Site (which I can't remote debug). I've tossed in some code to email me when confirmation fails (so that I can see the userId and code it was trying to confirm with) and I've verified that the code it's

Identity 2.0 Code First Table Renaming

*爱你&永不变心* 提交于 2019-12-02 07:19:58
问题 I'm trying to rename the identity tables to Roles, Users, UserRoles, UserLogins and UserClaims. I partially succeeded doing and using the command Update-Table updates my database. However I cant seem to be able to get rid off the AspNetUsers table, it always gets generated with only one column, the Id column, although I get another Users table with the full list of columns, and another Id column. The script generated by Update-Database Applying automatic migration: 201501190035078

asp.net identity expire bearer token after 20 min

泄露秘密 提交于 2019-12-02 06:00:38
问题 i have a web service, users can login to service and give bearer token. in local everything is good, but in server (shared host, windows 2012, iis 8.5) after 20 min, token has been expired !!! my AccessTokenExpireTimeSpan is : AccessTokenExpireTimeSpan = TimeSpan.FromDays(900), also in my first request, i give a delay about 5 sec. what is problem ? 回答1: I asume that you in production have multiple servers. And ASP.NET Identity is using the server's machine key to generate the token bearer. So