ExternalLoginConfirmation UserManager.CreateAsync fails: cannot insert null PashwordHash

358 Views Asked by At

MVC 5 with Dapper and User < int >

I followed ASP.Net's MVC 5 Guidance for Google OAuth2

I set up UseGoogleAuthentication in Startup.ConfigureAuth

Clicking the Google login button all seems to work, until the user tries to finalize to connection to the web app in

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)

In the basic template of code created, when I created the project, the function creates a user object and tries to create the User:

var user = new PortalUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user);

Then I get the lovely error:

Source: .Net SqlClient Data Provider
Target: Void OnError(System.Data.SqlClient.SqlException, Boolean, System.Action`1[System.Action])
Type:   SqlException
Message:    Cannot insert the value NULL into column 'PasswordHash', table 'WebApplication1.dbo.AspNetusers'; column does not allow nulls. INSERT fails.

The statement has been terminated.

So, how am I supposed to pass a password hash, from an External Login?

Or - do I allow nulls in the table?

Or - is there some aspect of the UserManager / UserStore / PortalClaimsIdentityFactory that I'm not fulfilling (overriding) because I'm using User < int > User keys?

0

There are 0 best solutions below