source: PostgreSqlDotnetCore/Areas/Identity/Pages/Account/Logout.cshtml.cs@ 6782104

main
Last change on this file since 6782104 was 2aea0fd, checked in by ElenaMoskova <elena.moskova99@…>, 2 months ago

init commit Elena

  • Property mode set to 100644
File size: 1.3 KB
Line 
1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3#nullable disable
4
5using System;
6using System.Threading.Tasks;
7using Microsoft.AspNetCore.Authorization;
8using Microsoft.AspNetCore.Identity;
9using Microsoft.AspNetCore.Mvc;
10using Microsoft.AspNetCore.Mvc.RazorPages;
11using Microsoft.Extensions.Logging;
12
13namespace PostgreSqlDotnetCore.Areas.Identity.Pages.Account
14{
15 public class LogoutModel : PageModel
16 {
17 private readonly SignInManager<IdentityUser> _signInManager;
18 private readonly ILogger<LogoutModel> _logger;
19
20 public LogoutModel(SignInManager<IdentityUser> signInManager, ILogger<LogoutModel> logger)
21 {
22 _signInManager = signInManager;
23 _logger = logger;
24 }
25
26 public async Task<IActionResult> OnPost(string returnUrl = null)
27 {
28 await _signInManager.SignOutAsync();
29 _logger.LogInformation("User logged out.");
30 if (returnUrl != null)
31 {
32 return LocalRedirect(returnUrl);
33 }
34 else
35 {
36 // This needs to be a redirect so that the browser performs a new
37 // request and the identity for the user gets updated.
38 return RedirectToPage();
39 }
40 }
41 }
42}
Note: See TracBrowser for help on using the repository browser.