Created
November 18, 2013 06:21
-
-
Save WaseemTheDream/7523466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (ModelState.IsValid) | |
{ | |
// Insert a new user into the database | |
using (UsersContext db = new UsersContext()) | |
{ | |
UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower()); | |
// Check if user already exists | |
if (user == null) | |
{ | |
// Insert name into the profile table | |
db.UserProfiles.Add(new UserProfile { UserName = model.UserName }); | |
db.SaveChanges(); | |
} | |
OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName); | |
OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false); | |
return RedirectToLocal(returnUrl); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment