main
Last change
on this file since 99d0ecc was 2aea0fd, checked in by ElenaMoskova <elena.moskova99@…>, 4 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 |
|
---|
5 | using System;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using Microsoft.AspNetCore.Authorization;
|
---|
8 | using Microsoft.AspNetCore.Identity;
|
---|
9 | using Microsoft.AspNetCore.Mvc;
|
---|
10 | using Microsoft.AspNetCore.Mvc.RazorPages;
|
---|
11 | using Microsoft.Extensions.Logging;
|
---|
12 |
|
---|
13 | namespace 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.