forked from Azure/azure-sdk-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountController.cs
More file actions
37 lines (34 loc) · 1.04 KB
/
AccountController.cs
File metadata and controls
37 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using APIViewWeb.Repositories;
using APIViewWeb.Models;
namespace APIViewWeb.Controllers
{
[AllowAnonymous]
public class AccountController : Controller
{
private readonly UserPreferenceCache _preferenceCache;
public AccountController(UserPreferenceCache preferenceCache)
{
_preferenceCache = preferenceCache;
}
[HttpGet]
public async Task<IActionResult> Login(string returnUrl = "/")
{
await HttpContext.SignOutAsync();
if (!Url.IsLocalUrl(returnUrl))
{
returnUrl = "/";
}
return Challenge(new AuthenticationProperties() { RedirectUri = returnUrl }, "GitHub");
}
[HttpGet]
public async Task<IActionResult> Logout()
{
await HttpContext.SignOutAsync();
return RedirectToPage("/Login");
}
}
}