diff --git a/Controllers/AppController.cs b/Controllers/AppController.cs new file mode 100644 index 0000000..a0056ea --- /dev/null +++ b/Controllers/AppController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using EFB.Models; +using Microsoft.AspNetCore.Http; +using EFB.Sessions; + +namespace EFB.Controllers +{ + public class AppController : Controller + { + private readonly ILogger _logger; + + public AppController(ILogger logger) + { + _logger = logger; + } + + public IActionResult Index() + { + //Check to see what point on the application the user is at and where they should be sent + UserModel User = HttpContext.Session.GetObject("User"); + if (User != null) + { + if (User.Route == null) + { + return RedirectToAction("Index", "Route"); + }else{ + return RedirectToAction("Index", "App"); + } + }else{ + return RedirectToAction("Index", "Home"); + } + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View("Error!"); + } + } +} \ No newline at end of file diff --git a/Controllers/RouteController.cs b/Controllers/RouteController.cs new file mode 100644 index 0000000..15f2b84 --- /dev/null +++ b/Controllers/RouteController.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Http; +using EFB.Models; +using EFB.Sessions; + +namespace EFB.Controllers +{ + public class RouteController : Controller + { + private readonly ILogger _logger; + + public RouteController(ILogger logger) + { + _logger = logger; + } + + public IActionResult Index() + { + //Check the user has a valid login + UserModel User = HttpContext.Session.GetObject("User"); + if (User == null || User.Route != null || User.Token.IsExpired()) + { + return RedirectToAction("Index", "Home"); + } + + return View(); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View("Error!"); + } + } +} \ No newline at end of file diff --git a/Controllers/UserController.cs b/Controllers/UserController.cs index 137160b..00a3971 100644 --- a/Controllers/UserController.cs +++ b/Controllers/UserController.cs @@ -72,7 +72,7 @@ namespace EFB.Controllers //Using Session Extensions (Store the user session) HttpContext.Session.SetObject("User", user); - return RedirectToAction("App", "Home"); + return RedirectToAction("Index", "App"); }else{ TempData["Error"] = login.error_description; TempData["email"] = email; diff --git a/Views/Route/Index.cshtml b/Views/Route/Index.cshtml new file mode 100644 index 0000000..24c48e4 --- /dev/null +++ b/Views/Route/Index.cshtml @@ -0,0 +1,46 @@ +@{ + ViewData["Title"] = "Route Info"; +} + +
+ +
+
+

Route Info

+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ + + @{ + if (TempData["Error"] != null) + {//If an error has been flagged, information will be displayed to the user + +
+
+ +
+ Warning! @TempData["Error"]
+ } + } +
+
+
+ +
+ +
+ +
diff --git a/wwwroot/images/RouteImage.png b/wwwroot/images/RouteImage.png new file mode 100644 index 0000000..5a6fc8c Binary files /dev/null and b/wwwroot/images/RouteImage.png differ