Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.UseFacebookAuthentication(
- appId: "xxxxxx",
- appSecret: "xxxxxx");
- app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
- {
- ClientId = "ssssss",
- ClientSecret = "sssss"
- });
- public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
- {
- var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
- if (loginInfo == null)
- {
- return RedirectToAction("Login");
- }
- // Sign in the user with this external login provider if the user already has a login
- var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
- switch (result)
- {
- case SignInStatus.Success:
- return RedirectToLocal(returnUrl);
- case SignInStatus.LockedOut:
- return View("Lockout");
- case SignInStatus.RequiresVerification:
- return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
- case SignInStatus.Failure:
- default:
- // If the user does not have an account, then prompt the user to create an account
- ViewBag.ReturnUrl = returnUrl;
- ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
- var viewModel = new ExternalLoginConfirmationViewModel
- {
- Email = loginInfo.Email
- };
- ViewBag.Title = "Register";
- return View("ExternalLoginConfirmation", viewModel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement