104 lines
2.8 KiB
C#
104 lines
2.8 KiB
C#
using Journeys_WantHome.Models;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Diagnostics;
|
|
using static DbTableClass;
|
|
|
|
namespace Journeys_WantHome.Controllers
|
|
{
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly ILogger<HomeController> _logger;
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
private authToken _objToken;
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger, IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
_logger = logger;
|
|
|
|
this._httpContextAccessor = httpContextAccessor;
|
|
|
|
this._objToken = new authToken(this._httpContextAccessor);
|
|
|
|
kol myKol = new kol();
|
|
myKol.kol_name = "123";
|
|
|
|
kolDetial kolD = new kolDetial(myKol);
|
|
}
|
|
|
|
public IActionResult OptionList()
|
|
{
|
|
if (checkToken() == false)
|
|
{
|
|
HttpContext.Response.Cookies.Delete("token_key");
|
|
return Redirect("~/Root/Login");
|
|
}
|
|
|
|
if (this._objToken.user_perm != "system")
|
|
{
|
|
return Redirect("~/");
|
|
}
|
|
|
|
return View();
|
|
}
|
|
|
|
public IActionResult UserList()
|
|
{
|
|
if (checkToken() == false)
|
|
{
|
|
HttpContext.Response.Cookies.Delete("token_key");
|
|
return Redirect("~/Root/Login");
|
|
}
|
|
|
|
if (this._objToken.user_perm != "system") {
|
|
return Redirect("~/");
|
|
}
|
|
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Dashboard()
|
|
{
|
|
if (checkToken() == false)
|
|
{
|
|
HttpContext.Response.Cookies.Delete("token_key");
|
|
return Redirect("~/Root/Login");
|
|
}
|
|
|
|
return View();
|
|
}
|
|
|
|
public Boolean checkToken()
|
|
{
|
|
this._objToken = new authToken(this._httpContextAccessor);
|
|
|
|
if (this._objToken.user_isLogin == false)
|
|
{
|
|
HttpContext.Response.Cookies.Delete("token_key");
|
|
return false;
|
|
}
|
|
|
|
@ViewData["user_name"] = this._objToken.user_name;
|
|
ViewData["user_permtype"] = "一般使用者";
|
|
if (this._objToken.user_perm == "system")
|
|
{
|
|
ViewData["authMenu"] = "display:block;";
|
|
ViewData["user_permtype"] = "管理者";
|
|
}
|
|
else {
|
|
ViewData["authMenu"] = "display:none;";
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public IActionResult Error()
|
|
{
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
}
|
|
}
|
|
}
|