App_Code/MicroAuthHelper.cs

(开头部分) 14KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Activities.Validation;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using MicroDBHelper;
using MicroPublicHelper;
using MicroUserHelper;
using MicroLdapHelper;

namespace MicroAuthHelper
{

    /// <summary>
    /// MicroAuthHelper 的摘要说明
    /// </summary>
    public class MicroAuth
    {
        /// <summary>
        /// 检查身份验证共两步,传入两个参数ModuleID&ShortTableName,【第一步】先检查用户是否登录,没有的话跳转到登录页面,【第二步】根据两个参数检查页面权限,防止利用有操作权限的页面对没有操作权限的页面进行操作
        /// </summary>
        /// <param name="ModuleID"></param>
        /// <param name="ShortTableName"></param>
        public static void CheckAuth(string ModuleID, string ShortTableName)
        {
            //第一步
            CheckLogin();

            //第二步
            if (!CheckPageAuth(ModuleID, ShortTableName))
            {
                HttpContext.Current.Response.Redirect("~/Views/Msg/DenyURLError");
                HttpContext.Current.Response.End();
            }
        }

        /// <summary>
        /// 检查用户是否登录,没有登录时跳转到登录页面。通常用于“.ashx”页面,因“.aspx”页面已经过母版页验证
        /// </summary>
        public static void CheckLogin()
        {
            Boolean GetIsLogin = ((MicroUserInfo)HttpContext.Current.Session["UserInfo"]).GetIsLogin();
            if (!GetIsLogin)
            {
                HttpContext.Current.Response.Redirect("~/Views/UserCenter/Login");
                HttpContext.Current.Response.End();
            }
        }

        public static Boolean CheckIsLogin()
        {
            return ((MicroUserInfo)HttpContext.Current.Session["UserInfo"]).GetIsLogin();
        }

        /// <summary>
        /// 检查用户是否有当前页面的浏览权限,没有的话跳转到Msg页面并提示没有权限浏览
        /// </summary>
        /// <param name="ModuleID"></param>
后面还有 300 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。