From 096bd04080b6a289554f255fa6e27f2604584e9c Mon Sep 17 00:00:00 2001 From: Isaiah Williams Date: Wed, 20 Jun 2018 08:40:54 -0500 Subject: [PATCH] Added the missing account controller. (#41) --- CHANGELOG.md | 1 + .../SmartOffice.Functions.csproj | 2 +- .../Controllers/AccountController.cs | 58 +++++++++++++++++++ src/SmartOffice/SmartOffice.csproj | 8 ++- .../Views/Account/AccessDenied.cshtml | 8 +++ 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/SmartOffice/Controllers/AccountController.cs create mode 100644 src/SmartOffice/Views/Account/AccessDenied.cshtml diff --git a/CHANGELOG.md b/CHANGELOG.md index 91dc67f..4ea965b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The following issues were addressed with this release - Added partitioning to select collections. Please note that this change is a **breaking** change. If you have an existing deployment you will need to delete all collections excepted for the *Environments* collection. +- Added the missing account controller to enable the access denied page and sign out capability - Modified the processing restrictions - Maximum dequeue count is now configured to 3 - Maximum number of records dequeued is now configured to 14 diff --git a/src/SmartOffice.Functions/SmartOffice.Functions.csproj b/src/SmartOffice.Functions/SmartOffice.Functions.csproj index ea778a1..291fcbd 100644 --- a/src/SmartOffice.Functions/SmartOffice.Functions.csproj +++ b/src/SmartOffice.Functions/SmartOffice.Functions.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/SmartOffice/Controllers/AccountController.cs b/src/SmartOffice/Controllers/AccountController.cs new file mode 100644 index 0000000..13bd720 --- /dev/null +++ b/src/SmartOffice/Controllers/AccountController.cs @@ -0,0 +1,58 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// ----------------------------------------------------------------------- + +namespace Microsoft.Partner.SmartOffice.Controllers +{ + using AspNetCore.Mvc; + using Microsoft.AspNetCore.Authentication; + using Microsoft.AspNetCore.Authentication.Cookies; + using Microsoft.AspNetCore.Authentication.OpenIdConnect; + + public class AccountController : Controller + { + // + // GET: /Account/SignIn + [HttpGet] + public IActionResult SignIn() + { + return Challenge( + new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectDefaults.AuthenticationScheme); + } + + // + // GET: /Account/SignOut + [HttpGet] + public IActionResult SignOut() + { + string callbackUrl = Url.Action(nameof(SignedOut), "Account", values: null, protocol: Request.Scheme); + + return SignOut(new AuthenticationProperties { RedirectUri = callbackUrl }, + CookieAuthenticationDefaults.AuthenticationScheme, OpenIdConnectDefaults.AuthenticationScheme); + } + + // + // GET: /Account/SignedOut + [HttpGet] + public IActionResult SignedOut() + { + if (HttpContext.User.Identity.IsAuthenticated) + { + // Redirect to home page if the user is authenticated. + return RedirectToAction(nameof(HomeController.Index), "Home"); + } + + return View(); + } + + // + // GET: /Account/AccessDenied + [HttpGet] + public IActionResult AccessDenied() + { + return View(); + } + } +} diff --git a/src/SmartOffice/SmartOffice.csproj b/src/SmartOffice/SmartOffice.csproj index 39294e5..9e26d05 100644 --- a/src/SmartOffice/SmartOffice.csproj +++ b/src/SmartOffice/SmartOffice.csproj @@ -20,7 +20,7 @@ - + @@ -33,4 +33,10 @@ + + + $(IncludeRazorContentInPack) + + + diff --git a/src/SmartOffice/Views/Account/AccessDenied.cshtml b/src/SmartOffice/Views/Account/AccessDenied.cshtml new file mode 100644 index 0000000..2b89710 --- /dev/null +++ b/src/SmartOffice/Views/Account/AccessDenied.cshtml @@ -0,0 +1,8 @@ +@{ + ViewData["Title"] = "Access Denied"; +} + +
+

Access Denied.

+

You do not have access to this resource.

+
\ No newline at end of file