コード例 #1
0
        public VwLoginInfo qryLoginAuth(string account)
        {
            string      sql        = this.getSelectSql("VwLoginInfoSqlProvider", "chkLoginAccountAuth");
            VwLoginInfo bean       = new VwLoginInfo();
            var         resultList = QueryTableListBySql(sql, new { ACCOUNT = account });

            foreach (var row in resultList)
            {
                bean.loginType = row.LOGIN_TYPE;
            }
            return(bean);
        }
コード例 #2
0
        public JsonResult login(string userId, string userPwd)
        {
            string token       = "";
            string loginName   = "";
            int    loginType   = 0;
            string loginUserId = "";
            string loginMsg    = "";

            string title = "";   //要判斷校長及主管 的簽核權限
            Dictionary <string, dynamic> result = service.loginCheck(userId, userPwd);

            if (result["status"].ToString() == "success" || result["status"].ToString() == "warn")
            {
                VwLoginInfo vwLoginInfo = result["loginInfo"];
                title = vwLoginInfo.title;
                optEventRecord(vwLoginInfo.userId, vwLoginInfo.account, "使用者:" + vwLoginInfo.name + "(" + vwLoginInfo.account + "), 登入");
                try{
                    token = new JwtUtils().EnCodeJwt(vwLoginInfo);
                }catch (Exception e) {
                    logger.Error(e, e.Message);
                }
                loginName   = vwLoginInfo.name + "(" + vwLoginInfo.school + ")";
                loginType   = vwLoginInfo.loginType;
                loginUserId = vwLoginInfo.userId;
                if (loginType.ToString() == "3" || loginType.ToString() == "4")
                {
                    loginMsg = new DrugsNoticeService().getLoginMsgByAdmin(loginType.ToString(), userId.ToString());
                }
                else
                {
                    loginMsg = new DrugsNoticeService().getLoginMsg(userId.ToString());
                }
            }
            string login_type = service.qryLoginAuth(userId);

            LoginAuthEnable model   = getLoginAuthEnable(login_type, title);
            string          jsonStr = "";

            if (!object.ReferenceEquals(model, null))
            {
                jsonStr = JsonConvert.SerializeObject(model);
            }

            return(Json(new {
                status = result["status"].ToString(),
                msg = result["msg"].ToString(),
                token = token,
                loginName = loginName,
                loginType = loginType,
                loginMsg = loginMsg,
                auth = jsonStr
            }));
        }
コード例 #3
0
        public Dictionary <string, dynamic> loginCheck(string userId, string userPwd)
        {
            Dictionary <string, dynamic> result = new Dictionary <string, dynamic>();

            using (SqlConnection dbConn = new SqlConnection(DbConnection.connString)){
                try{
                    dbConn.Open();
                    dao.dbConn = dbConn;
                    if (dao.loginUserExists(userId))
                    {
                        VwLoginInfo info = dao.qryLoginInfo(userId);
                        if (info.password == new SecurityUtils().getCsrcEnCrypt(userPwd) && info.status == "Y")
                        {
                            if (info.loginType != 4 && userPwd == "1qaz2wsx")
                            {
                                result.Add("status", "warn");
                                info.isWarn = "Y";
                            }
                            else
                            {
                                result.Add("status", "success");
                                info.isWarn = "N";
                            }
                            result.Add("msg", "登入成功");
                            info.password = "";
                            result.Add("loginInfo", info);
                        }
                        else if (info.password == new SecurityUtils().getCsrcEnCrypt(userPwd) && info.status == "N")
                        {
                            result.Add("status", "fail");
                            result.Add("msg", "此帳號已被停用!!");
                        }
                        else
                        {
                            result.Add("status", "fail");
                            result.Add("msg", "登入失敗,密碼錯誤!!");
                        }
                    }
                    else
                    {
                        result.Add("status", "fail");
                        result.Add("msg", "登入失敗,無效帳號!!");
                    }
                }catch (Exception e) {
                    result.Add("status", "exception");
                    result.Add("msg", "處理您的要求時發生錯誤!!");
                    logger.Error(e, e.Message);
                }
            }
            return(result);
        }
コード例 #4
0
        /// <summary>
        /// 回傳登入類別
        /// loginType = 4 最高權限; 2 , 3 學校單位
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string qryLoginAuth(string userId)
        {
            VwLoginInfo model = new VwLoginInfo();

            using (SqlConnection dbConn = new SqlConnection(DbConnection.connString)){
                try
                {
                    dbConn.Open();
                    dao.dbConn = dbConn;
                    model      = dao.qryLoginAuth(userId);
                }
                catch (Exception e)
                {
                    logger.Error(e, e.Message);
                }
            }
            return(model.loginType.ToString());
        }
コード例 #5
0
        public VwLoginInfo qryLoginInfo(string account)
        {
            string             sql      = this.getSelectSql("VwLoginInfoSqlProvider", "selectLoginAccount");
            List <VwLoginInfo> userList = new List <VwLoginInfo>();
            var resultList = QueryTableListBySql(sql, new { ACCOUNT = account });

            foreach (var row in resultList)
            {
                VwLoginInfo bean = new VwLoginInfo();
                bean.userId           = row.USER_ID;
                bean.password         = row.PASSWORD;
                bean.account          = row.ACCOUNT;
                bean.school           = row.SCHOOL;
                bean.schoolSystemSno  = row.SCHOOL_SYSTEM_SNO;
                bean.schoolSystemName = row.SCHOOL_SYSTEM_NAME;
                bean.schoolPresident  = row.SCHOOL_PRESIDENT;
                bean.name             = row.NAME;
                bean.job           = row.JOB;
                bean.title         = row.TITLE;
                bean.titleName     = row.TITLE_NAME;
                bean.phone         = row.PHONE;
                bean.email         = row.EMAIL;
                bean.countyId      = row.COUNTY_ID;
                bean.city          = row.CITY;
                bean.road          = row.ROAD;
                bean.countyName    = row.COUNTY_NAME;
                bean.cityName      = row.CITY_NAME;
                bean.roadName      = row.ROAD_NAME;
                bean.schoolAddress = row.SCHOOL_ADDRESS;
                bean.loginType     = row.LOGIN_TYPE;
                bean.loginTypeName = row.LOGIN_TYPE_NAME;
                bean.status        = row.STATUS;
                bean.showFlag      = row.SHOW_FLAG;
                userList.Add(bean);
            }
            if (userList.Count == 0)
            {
                return(null);
            }
            return(userList[0]);
        }