asp.net-identity-2

Updating user by UserManager.Update() in ASP.NET Identity 2

一曲冷凌霜 提交于 2019-12-20 11:55:17
问题 I use ASP.NET Identity 2 in an MVC 5 project and I want to update Student data by using UserManager.Update() method. However, as I inherit from ApplicationUser class, I need to map Student to ApplicationUser before calling update method. On the other hand, when using the approach that I also used for creating new Student, there is an error due to concurrency as I create a new instance rather than update. As I am bored to solve the problem using AutoMapper , I need a stable fix to solve the

How to list users with role names in ASP.NET MVC 5

落爺英雄遲暮 提交于 2019-12-20 10:37:48
问题 I have default project template of ASP.NET MVC 5 web site and I am trying to list all users with role names (not IDs). The query is: db.Users.Include(u => u.Roles).ToList() Then I want to print the role names with something like: @string.Join(", ", user.Roles.Select(r => r.RoleId)) The problem is that I can reach only RoleId , not Role class where Name and other properties are stored. I could run another select to get all roles and then use that as a lookup. Or write a join in the query

Asp.Net Identity save user without email

巧了我就是萌 提交于 2019-12-20 08:59:20
问题 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? 回答1: 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

Identity 2.0 with custom tables

安稳与你 提交于 2019-12-20 08:18:43
问题 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

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

☆樱花仙子☆ 提交于 2019-12-20 07:31:27
问题 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

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

馋奶兔 提交于 2019-12-20 07:31:23
问题 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

Stuck between two errors in an Azure OAuth2 token request

天大地大妈咪最大 提交于 2019-12-18 22:32:35
问题 I am implementing an OAuth2 provider for OWIN and Azure Active Director. FWIW, at this time the OpenId Connect option doesn't fit the requirements for this work. I get an auth code, and returned to my reply url with the auth_code, state, and make the request for a token to "scheme://login.windows.net/{myguid}/oauth2/token. // Build up the body for the token request var body = new List<KeyValuePair<string, string>>(); body.Add(new KeyValuePair<string, string>("grant_type", "authorization_code"

getting #error=unsupported_response_type&error_description=AADSTS70005: with token request

ぐ巨炮叔叔 提交于 2019-12-18 07:16:09
问题 I am trying to implement a OAuth2 implicit grant flow in an IOS app. In this case it requires a token request instead of a code request because you can't share the client secret in a native app safely. so a request like this yields a login form: https://login.windows.net/<tenantid>/oauth2/authorize?api-version=1.0&client_id=<client id>&response_type=token&redirect_uri=shp-apps://localhost:44300/?ReturnUrl=%2F&resource=https://graph.windows.net After successfully login I get this error: #error

How can customize Asp.net Identity 2 username already taken validation message?

久未见 提交于 2019-12-17 18:50:15
问题 How can i customize Asp.net Identity 2 username already taken validation message(Name XYZ is already taken.)? Thanks 回答1: Well, I didn't find any simple solution to this issue. And by simple i mean modifying some message in a attribute/model/controller. One possible solution could be: After executing var result = await UserManager.CreateAsync(user, model.Password); In case that result is not successful you can check it's Errors property for the "Name XYZ is already taken." pattern and replace

ASP.Net Identity 2 - custom response from OAuthAuthorizationServerProvider

主宰稳场 提交于 2019-12-17 18:44:09
问题 This question is continuation of my previous one: ASP.Net Identity 2 login using password from SMS - not using two-factor authentication I've build my custom OAuthAuthorizationServerProvider to support custom grant_type. My idea was to create grant_type of sms that will allow user to generate one-time access code that will be send to his mobile phone and then user as password when sending request with grant_type of password. Now after generating, storing and sending via SMS that password I'd