I have a Code First MVC 4 App, I have swapped Username for Email in SimpleMembership - which works fine.
I do that by changing Initialization to this:
// Initialize database for Account
WebSecurity.InitializeDatabaseConnection("MyEntities", "Users", "UserId", "Email", autoCreateTables: true);
I have a Facebook App which I want to use for login. I have tested this on a vanilla (username based) Simple Membership site and it works fine.
However, when I try and login using the Email/Password Simple Membership MVC 4 site - it works as far as this:
Associate your Facebook account.
Association Form
You've successfully authenticated with Facebook. Please enter a user name for this site below and click the Confirm button to finish logging in.
no matter what I enter here - I get this error:
"The username supplied is invalid."
db.UserProfiles.Add(new UserProfile { UserName = model.UserName });
db.SaveChanges();
OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
Any idea how I can get this to work (and secondarily request both a username and an email at this stage - or an email only if that's easier). Thanks.
I fixed it by adding an email field to the confirmation form - then changing the code to this:
db.UserProfiles.Add(new UserProfile { UserName = model.UserName, Email = model.Email });
db.SaveChanges();
OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.Email);