Logout.cshtml.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Authorization;
  6. using Microsoft.AspNetCore.Identity;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Microsoft.AspNetCore.Mvc.RazorPages;
  9. using Microsoft.Extensions.Logging;
  10. using Console = HyperCube.Utils.AdvConsole;
  11. namespace HyperCube.Areas.Identity.Pages.Account
  12. {
  13. [AllowAnonymous]
  14. public class LogoutModel : PageModel
  15. {
  16. private readonly SignInManager<IdentityUser> _signInManager;
  17. //private readonly ILogger<LogoutModel> _logger;
  18. public LogoutModel(SignInManager<IdentityUser> signInManager, ILogger<LogoutModel> logger)
  19. {
  20. _signInManager = signInManager;
  21. //_logger = logger;
  22. }
  23. public async Task<IActionResult> OnGet()
  24. {
  25. await _signInManager.SignOutAsync();
  26. //_logger.LogInformation("User logged out.");
  27. Console.WriteLine("User logged out.");
  28. return LocalRedirect("~/");
  29. }
  30. }
  31. }