Foxtable(狐表)用户栏目专家坐堂 → 移动版检测是否登陆


  共有2584人关注过本帖平板打印复制链接

主题:移动版检测是否登陆

帅哥哟,离线,有人找我吗?
yifan3429
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2466 积分:22761 威望:0 精华:0 注册:2011/3/29 17:14:00
移动版检测是否登陆  发帖心情 Post By:2018/2/23 18:14:00 [只看该作者]

下面的使用的内部函数调用  会直接进入网页  不会被登陆与否监控  要怎么检测后必须登陆呢

Dim wb As New WeUI '定义一个基于weui框架的网页生成器
Dim e As RequestEventArgs = args(0)
'Dim u As String = e.cookies("name")
Dim s As String = e.cookies("部门")
'Dim x As String = e.cookies("岗位")
'For Each dr As DataRow In DataTables("财务流水").sqlSelect("[部门] = '" & s & "'","日期 Desc")
With wb.AddTable("","Table1")
    '.MergeCols = 2 '合并左边2列
    .Alternate = 3
    Dim nms() As String = {"经手人","编号","科目","摘要","收入","支出","日期" }
    .Head.AddRow(nms)
    .body.AddRow("汇总","","","",DataTables("财务流水").sqlcompute("sum(收入)","[部门] = '" & s & "'"),DataTables("财务流水").sqlcompute("sum(支出)","[部门] = '" & s & "'"))
    For Each r As DataRow In DataTables("财务流水").sqlSelect("[部门] = '" & s & "'", "", "日期 Desc")
        With .Body.AddRow(r("经手人"),r("编号"),r("科目"),r("摘要"))
            .AddCell(Format(r("收入"),"#0.00"))
            .AddCell(Format(r("支出"),"#0.00"))
            .AddCell(Format(r("日期"),"MM月dd日"))
        End With
    Next
End With
e.WriteString(wb.Build)

如何让下面的身份验证能生效
'身份验证
Dim Verified As Boolean '用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") '从cookie中获取用户名
Dim Password As String = e.Cookies("password") '从cookie中获取用户密码
If e.Path = "logon.htm" '如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If
'Dim dr As DataRow  自定义窗口使用 密码是明码
'dr = DataTables("用户表").Find("name = '" & UserName & "'")
'If dr IsNot Nothing AndAlso Password = dr("password") Then
'Verified  = True
Dim dr As DataRow
dr = DataTables("用户表").Find("name = '" & UserName & "'")
If dr IsNot Nothing AndAlso dr("config").contains(MD5Encrypt(password)) Then
    Verified  = True
    For Each u As UserInfo In users
        output.show(u.name)
        If u.name = username Then
            'msgbox(u.group)
            'msgbox(u.Roles)
            wb.AppendCookie("部门",u.group)
            wb.AppendCookie("岗位",u.Roles)
            wb.AppendCookie("name",u.name)
        End If
    Next
End If

If Verified AndAlso e.Path = "logon.htm"  Then '如果用户访问的是登录页,且身份验证成功
    wb.AppendCookie("username",UserName) '将用户名和密码写入cookie
    wb.AppendCookie("password",Password)
    wb.InsertHTML("<meta http-equiv='Refresh' c>") '直接跳转到首页
    e.WriteString(wb.Build) '生成网页
    Return '必须的
ElseIf Verified = False AndAlso e.Path <> "logon.htm" Then '如果用户身份验证失败,且访问的不是登录页面
    wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
    e.WriteString(wb.Build) '生成网页
    Return '必须的
End If

 回到顶部
总数 16 1 2 下一页