Ejemplo n.º 1
0
 public IActionResult Logout()
 {
     AdminDto.SetAdminMode(DateTime.Now.AddMinutes(-10));
     SetSession(SessionSetting.AdminSession, AdminDto);
     if (Request.Headers.TryGetValue("Referer", out StringValues value))
     {
         var val = value.ToSafeString();
         return(Redirect(val));
     }
     return(Redirect("/"));
 }
Ejemplo n.º 2
0
 public async Task <IActionResult> Login([FromBody] Req <AdminModeDto> request)
 {
     if (AdminDto.IsAdminMode() == false)
     {
         //if (string.IsNullOrEmpty(request.OperatorPassword)) { return Error("TryAdminMode"); }
         if (await _adminApplication.CheckPassword(request.OperatorId, request.OperatorPassword, request) == false)
         {
             return(Error("密码不正确"));
         }
         AdminDto.SetAdminMode(DateTime.Now.AddMinutes(request.AdminModeTime));
         SetSession(SessionSetting.AdminSession, AdminDto);
     }
     return(Success());
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> AdminModeEditPost([FromBody] Req <AdminModeEditDto> request)
        {
            if (AdminDto.IsAdminMode() == false && await _adminApplication.GetMenuCheck(ViewData["MenuCode"].ToSafeString(), ViewData["ButtonCode"].ToSafeString()))
            {
                if (string.IsNullOrEmpty(request.OperatorPassword))
                {
                    return(Error("TryAdminMode"));
                }
                if (await _adminApplication.CheckPassword(request.OperatorId, request.OperatorPassword, request) == false)
                {
                    return(Error("密码不正确"));
                }
                AdminDto.SetAdminMode(DateTime.Now.AddMinutes(request.AdminModeTime));
                SetSession(SessionSetting.AdminSession, AdminDto);
            }

            var b = await _adminApplication.EditMenuMode(request);

            if (b == false)
            {
                return(Error(request.Message));
            }
            return(Success());
        }