Example #1
0
 public ActionResult HCRate()
 {
     if (!CommonInfo.IsLogin())
     {
         return(RedirectToAction("Signin", "Login"));
     }
     return(View());
 }
Example #2
0
 public ActionResult LectorMaintain()
 {
     if (!CommonInfo.IsLogin())
     {
         return(RedirectToAction("Index"));
     }
     ViewBag.Title  = "讲师维护";
     ViewBag.CurUrl = Url.Action("LectorMaintain");
     return(View());
 }
Example #3
0
        public ActionResult CourseMaintain()
        {
            if (!CommonInfo.IsLogin())
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.Title  = "课程维护";
            ViewBag.CurUrl = Url.Action("CourseMaintain");
            var model = new TCourseMaintainModel();

            return(View(model));
        }
Example #4
0
        public ActionResult Signin(LogInModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            string ad  = model.Username;
            string pwd = model.Password;
            string msg = "";

            //CacheFactory.ClearCache(); //TODO remove

            try
            {
                UserBasicInfo domainUser = null;
                if (!CommonInfo.IsLogin())
                {
                    var user = SysUserInfo.GetUserInfoByAd(ad);
                    if (user == null)
                    {
                        msg = "账号不存在,请先注册! Login user not exist, please register first!";
                        ModelState.AddModelError("", msg);
                        return(View());
                    }

                    //验证域密码
                    if (user != null)
                    {
                        domainUser = new UserBasicInfo(user.id, user.ADAccount, user.Email, user.FullName, user.IsAdmin);
                    }
                    if (user == null /*|| false == ConfigInfo.DebugRun*/)
                    {
                        domainUser = new ActiveDirectoryHelper().GetDomainUser(ad, pwd, out msg);
                        if (domainUser == null)
                        {
                            ModelState.AddModelError("", msg);
                            return(View());
                        }
                        if (user != null)
                        {
                            domainUser = new UserBasicInfo(user.id, user.ADAccount, user.Email, user.FullName, user.IsAdmin);
                        }
                        // 更新用户邮箱
                        if (user != null && string.IsNullOrEmpty(domainUser.Email) == false &&
                            domainUser.Email != user.Email)
                        {
                            user.Email = domainUser.Email;
                            SysUserInfo.Update(user);
                        }
                    }
                    // 帐号被停用
                    if (!user.IsValid)
                    {
                        msg = "账号已被停用. Your account was disabled.";
                        ModelState.AddModelError("", msg);
                        return(View());
                    }
                }
                else
                {
                    domainUser = CommonInfo.CurrentUser;
                }
                CommonInfo.Login(domainUser);
                SysUserInfo.UpdateUserLoginTimeByAd(ad);
                return(RedirectToLocal(model.ReturnUrl));
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(this.GetType(), ex);
                ModelState.AddModelError("", ex);
                return(View());
            }
        }
Example #5
0
        public ActionResult Signin(LogInModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            string ad  = model.Username;
            string pwd = model.Password;
            string msg = "";

            try
            {
                UserBasicInfo domainUser = null;
                if ("guest".Equals(ad, StringComparison.InvariantCultureIgnoreCase))
                {
                    //特殊帐号
                    var user = SysUserInfo.GetUserInfoByAd("guest");
                    domainUser = new UserBasicInfo(user.id, user.FullName, user.Email, user.FullName, user.IsAdmin);
                }
                else if (!CommonInfo.IsLogin())
                {
                    var user = SysUserInfo.GetUserInfoByAd(ad);
                    if (user == null)
                    {
                        msg = "账号不存在,请先注册! Login user not exist, please register first!";
                        ModelState.AddModelError("", msg);
                        return(View());
                    }

                    //验证域密码
                    domainUser = new ActiveDirectoryHelper().GetDomainUser(ad, pwd, out msg);
//true for debug only
#if false
                    domainUser = new UserBasicInfo(user.id, user.ADAccount, user.Email, user.FullName, user.IsAdmin);
#endif

                    if (domainUser == null)
                    {
                        ModelState.AddModelError("", msg);
                        return(View());
                    }

                    domainUser.UserID  = user.id;
                    domainUser.IsAdmin = user.IsAdmin;
                    // 更新用户邮箱
                    if (!string.IsNullOrEmpty(domainUser.Email) &&
                        0 != string.Compare(domainUser.Email, user.Email, true)
                        )
                    {
                        user.Email = domainUser.Email;
                        SysUserInfo.Update(user);
                    }

                    // 帐号被停用
                    if (!user.IsValid)
                    {
                        msg = "账号已被停用. Your account was disabled.";
                        ModelState.AddModelError("", msg);
                        return(View());
                    }
                }
                else
                {
                    domainUser = CommonInfo.CurrentUser;
                }
                CommonInfo.Login(domainUser);
                SysUserInfo.UpdateUserLoginTimeByAd(ad);
                return(RedirectToLocal(model.ReturnUrl));
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(this.GetType(), ex);
                ModelState.AddModelError("", ex);
                return(View());
            }
        }