|
Imports System.Xml.XPath
Imports Microsoft.VisualBasic
Public Class SiteUser
Private MyIsLoggedIn As Boolean = False
Public ReadOnly Property IsLoggedIn() As Boolean
Get
Return MyIsLoggedIn
End Get
End Property
Private MyUserType As UserType = UserType.Anonymous
Public ReadOnly Property UserType() As UserType
Get
Return MyUserType
End Get
End Property
Private MyUserName As String = ""
Public ReadOnly Property UserName() As String
Get
Return MyUserName
End Get
End Property
Public Sub New(ByVal context As HttpContext)
If context.User.Identity.IsAuthenticated Then
MyIsLoggedIn = True
MyUserName = context.User.Identity.Name
Dim db As New Database()
Dim el As XElement = db.Data.XPathSelectElement("Users/User[@Name='" & UserName & "']")
If el Is Nothing Then Throw New Exception("Invalid User!")
MyUserType = [Enum].Parse(GetType(UserType), el.@Role)
End If
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Clayton Rumley is web developer for hire from Winnipeg, Manitoba, Canada.