Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. app.UseFacebookAuthentication(
  2. appId: "xxxxxx",
  3. appSecret: "xxxxxx");
  4.  
  5. app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
  6. {
  7. ClientId = "ssssss",
  8. ClientSecret = "sssss"
  9. });
  10.  
  11. public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
  12. {
  13. var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
  14. if (loginInfo == null)
  15. {
  16. return RedirectToAction("Login");
  17. }
  18.  
  19. // Sign in the user with this external login provider if the user already has a login
  20. var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
  21. switch (result)
  22. {
  23. case SignInStatus.Success:
  24. return RedirectToLocal(returnUrl);
  25. case SignInStatus.LockedOut:
  26. return View("Lockout");
  27. case SignInStatus.RequiresVerification:
  28. return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
  29. case SignInStatus.Failure:
  30. default:
  31. // If the user does not have an account, then prompt the user to create an account
  32. ViewBag.ReturnUrl = returnUrl;
  33. ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
  34. var viewModel = new ExternalLoginConfirmationViewModel
  35. {
  36. Email = loginInfo.Email
  37. };
  38. ViewBag.Title = "Register";
  39.  
  40. return View("ExternalLoginConfirmation", viewModel);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement