From 72cc12bdefdcca2bee5677e683f538d96a5ee694 Mon Sep 17 00:00:00 2001 From: anuragysingh Date: Thu, 29 Aug 2019 16:52:53 +0530 Subject: [PATCH] Display of invalid user upn: - Modified Startup Auth to provide invalid user UPN - Display of invalid user UPN in View --- .../App_Start/Startup.Auth.cs | 2 +- .../Controllers/AccountController.cs | 4 +++- .../Views/Account/InvalidUser.cshtml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/App_Start/Startup.Auth.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/App_Start/Startup.Auth.cs index e7cece7..7eb5d35 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/App_Start/Startup.Auth.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/App_Start/Startup.Auth.cs @@ -59,7 +59,7 @@ public void ConfigureAuth(IAppBuilder app, Autofac.IContainer container) if (upn == null || !validUpns.Contains(upn, StringComparer.OrdinalIgnoreCase)) { - context.OwinContext.Response.Redirect("/Account/InvalidUser"); + context.OwinContext.Response.Redirect("/Account/InvalidUser?upn=" + upn); context.HandleResponse(); } diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Controllers/AccountController.cs b/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Controllers/AccountController.cs index 96f4728..04f797d 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Controllers/AccountController.cs +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Controllers/AccountController.cs @@ -56,9 +56,11 @@ public ActionResult SignOutCallback() /// /// Invalid User /// + /// upn of unauthorized user /// Action Result - public ActionResult InvalidUser() + public ActionResult InvalidUser(string upn) { + this.ViewBag.Upn = upn; this.HttpContext.GetOwinContext().Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType); return this.View(); } diff --git a/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Views/Account/InvalidUser.cshtml b/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Views/Account/InvalidUser.cshtml index 6139e74..931cd79 100644 --- a/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Views/Account/InvalidUser.cshtml +++ b/Source/Microsoft.Teams.Apps.FAQPlusPlus.Configuration/Views/Account/InvalidUser.cshtml @@ -2,4 +2,4 @@ ViewBag.Title = "Invalid User"; }

@ViewBag.Title.

-

This user does not have the proper permissions for this action. Please sign in with a valid user credentials.

\ No newline at end of file +

This user does not have the proper permissions for this action. Please sign in with a valid user credentials. In case you are still unable to access the app please ask the app administrator to add @ViewBag.Upn to the list of users allowed to configure this app

\ No newline at end of file