Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task<IActionResult> OnGetLogin(string Id = "default")
- {
- if (Enum.IsDefined(typeof(AuthProviders), Id))
- {
- Console.WriteLine(Id);
- var resp = new ChallengeResult(Id,
- new AuthenticationProperties
- {
- IsPersistent = true,
- AllowRefresh = true,
- RedirectUri = Url.Content("/Account/Response/"+Id),
- });
- return resp;
- }
- else Console.WriteLine($"No Authentication provider exists with this name: {Id}");
- return new RedirectResult("/Account");
- }
- public async Task<IActionResult> OnGetResponse(string Id = "default")
- {
- var auth = await HttpContext.AuthenticateAsync(Id);
- Message = $"{(auth.Succeeded == true ? "Sikeres" : "Sikertelen")} bejelentkezés ide: {Id} :: {auth.Principal.Identity.Name}";
- if (auth.Succeeded)
- {
- HttpContext.Session.SetString($"{Id}:access_token", Accessor?.HttpContext?.GetTokenAsync(Id, "access_token").Result);
- var claimsIdentity = new ClaimsIdentity(auth.Principal.Identity);
- var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
- }
- return new RedirectResult("/Account");
- }
Advertisement
Add Comment
Please, Sign In to add comment