Permalink
Find file
e287687 Dec 6, 2016
38 lines (30 sloc) 1.03 KB
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Authorization;
using auth0search.Extensions;
namespace auth0search.Controllers
{
public class AccountController : Controller
{
IOptions<OpenIdConnectOptions> _options;
public AccountController(IOptions<OpenIdConnectOptions> options)
{
_options = options;
}
public IActionResult Login(string returnUrl = "/")
{
var lockContext = HttpContext.GenerateLockContext(_options.Value, returnUrl);
return View(lockContext);
}
[Authorize]
public IActionResult Logout()
{
HttpContext.Authentication.SignOutAsync("Auth0");
HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToAction("Index", "Home");
}
}
}