Fixed user being able to go to login screen despite being logged in
This commit is contained in:
parent
72124e7f15
commit
27bf158a7a
@ -2,6 +2,8 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using EFB.Sessions;
|
||||
|
||||
namespace EFB.Controllers
|
||||
{
|
||||
@ -16,6 +18,10 @@ namespace EFB.Controllers
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
//Ensure that the user is not already logged in
|
||||
UserModel user = HttpContext.Session.GetObject<UserModel>("User");
|
||||
if (user != null) return RedirectToAction("Index", "App");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,11 @@ namespace EFB.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
public async Task<IActionResult> Login(string email, string password)
|
||||
{
|
||||
//Ensure that the user is not already logged in
|
||||
UserModel user = HttpContext.Session.GetObject<UserModel>("User");
|
||||
if (user != null) return RedirectToAction("Index", "App");
|
||||
|
||||
if (!Form.FormAuthenticator.ValidateEMail(email))
|
||||
{
|
||||
@ -70,7 +72,7 @@ namespace EFB.Controllers
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
|
||||
UserModel user = new UserModel
|
||||
user = new UserModel
|
||||
{
|
||||
EMail = email,
|
||||
UserToken = new TokenModel
|
||||
@ -83,7 +85,6 @@ namespace EFB.Controllers
|
||||
//Using Session Extensions (Store the user session)
|
||||
HttpContext.Session.SetObject("User", user);
|
||||
return RedirectToAction("Index", "App");
|
||||
|
||||
}
|
||||
|
||||
public IActionResult Logout()
|
||||
|
Loading…
Reference in New Issue
Block a user