示例#1
0
 public IActionResult Index(FormAdminUser fuser)
 {
     if (ModelState.IsValid)
     {
         var    guid    = Guid.NewGuid();
         string session = guid.ToString().Replace("-", "").ToUpper();
         var    user    = _AdminUserContext.Login(fuser.UserName, fuser.Password, session);
         if (user != null)
         {
             //记录Session
             HttpContext.Session.SetString("UserId", user.Id.ToString());
             HttpContext.Session.SetString("UserSession", session);
             //跳转到系统首页
             return(RedirectToAction("Index", "Home"));
         }
     }
     foreach (var item in ModelState.Values)
     {
         if (item.Errors.Count > 0)
         {
             ViewBag.ErrorInfo = item.Errors[0].ErrorMessage;
             break;
         }
     }
     return(View(fuser));
 }
示例#2
0
        public IActionResult Init(FormAdminUser fuser)
        {
            var i = _AdminUserContext.InitRoot(fuser.UserName, fuser.Password);

            return(RedirectToAction("Index", "Login"));
        }