以下示例代码能否加上权限的指导 这样封装APP才完美
譬如
张三 有c1的权限
李四 有所有权限的授权
如何在用户登录成功时只看到自己授权的模块
HttpRequest事件代码:
Dim wb As New weui'身份验证
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
If UserName = "张三" AndAlso Password = "888" Then '实际使用的时候,请改为从数据库读取用户名和密码进行比较
Verified = True
ElseIf Username = "李四" AndAlso Password="999" Then
Verified = True
End If
'开始生成网页
Select Case e.path
Case "logon.htm" '登录页面
wb.AddPageTitle("","pageheader","销售系统","由湛江辉迅基于Foxtable开发")
If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") Then '判断是否是验证失败后的重新登录
wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 '如果用户通过登录按钮访问,则给用户一个2秒的提示.
End If
wb.AddForm("","form1","logon.htm")
With wb.AddInputGroup("form1","ipg1")
.AddInput("username","户名","text")
.AddInput("password","密码","password")
End With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "登录", "submit")
End With
Case "exit.htm" '退出登录
wb.DeleteCookie("username") '清除cookie中原来的用户名和密码
wb.DeleteCookie("password")
wb.InsertHTML("<meta http-equiv='Refresh' c>") '那么直接跳转到登录页面
Case "", "default.htm" '首页
wb.AddPageTitle("","pageheader","销售系统","由湛江辉迅基于Foxtable开发")
With wb.AddGrid("","g1")
.Add("c1","增加订单", "./images/button.png").Attribute = ""
.Add("c2","客户管理", "./images/cell.png", "http://www.foxtable.com")
End With
End Select
e.WriteString(wb.Build) '生成网页