check user login
This commit is contained in:
parent
1108fa47e0
commit
cd23c5b974
@ -6,6 +6,9 @@
|
|||||||
Public Property Email As String
|
Public Property Email As String
|
||||||
Public Property Language As String
|
Public Property Language As String
|
||||||
|
|
||||||
|
Public Property HasAccess As Boolean
|
||||||
|
Public Property IsAdmin As Boolean
|
||||||
|
|
||||||
Public ReadOnly Property FullName() As String
|
Public ReadOnly Property FullName() As String
|
||||||
Get
|
Get
|
||||||
Return Prename + " " + Name
|
Return Prename + " " + Name
|
||||||
|
|||||||
@ -27,15 +27,7 @@ Public Class ConfigModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetUserId() As Integer
|
|
||||||
Try
|
|
||||||
Dim oUserId As Integer = Database.GetScalarValue($"SELECT GUID FROM TBDD_USER WHERE USERNAME = '{Environment.UserName}'")
|
|
||||||
Return oUserId
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Return 0
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -21,6 +21,29 @@ Public Class UserModel
|
|||||||
Return oUser
|
Return oUser
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function CheckUserLogin(pUser As User) As User
|
||||||
|
Try
|
||||||
|
Dim oSql = $"SELECT * FROM [dbo].[FNDD_LOGIN_USER_MODULE] ('{pUser.Username}', 'SIG_PMENV_CR', 1)"
|
||||||
|
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||||
|
|
||||||
|
If oTable?.Rows.Count = 0 Then
|
||||||
|
Return pUser
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim oRow = oTable.Rows.Item(0)
|
||||||
|
Dim oHasAccess = oRow.ItemEx("MODULE_ACCESS", False)
|
||||||
|
Dim oIsAdmin = oRow.ItemEx("IS_ADMIN", False)
|
||||||
|
|
||||||
|
pUser.HasAccess = oHasAccess
|
||||||
|
pUser.IsAdmin = oIsAdmin
|
||||||
|
|
||||||
|
Return pUser
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return pUser
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function SelectUser() As User
|
Public Function SelectUser() As User
|
||||||
Try
|
Try
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {State.UserId}"
|
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {State.UserId}"
|
||||||
@ -47,4 +70,15 @@ Public Class UserModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function SelectUserId() As Integer
|
||||||
|
Try
|
||||||
|
Dim oUserId As Integer = Database.GetScalarValue($"SELECT GUID FROM TBDD_USER WHERE USERNAME = '{Environment.UserName}'")
|
||||||
|
Return oUserId
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return 0
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -44,9 +44,7 @@ Public Class frmMain
|
|||||||
ConfigManager.Save()
|
ConfigManager.Save()
|
||||||
Application.Restart()
|
Application.Restart()
|
||||||
Else
|
Else
|
||||||
FormHelper.ShowErrorMessage(New ApplicationException("No Database configured. Application will close!"), "Form Load")
|
Throw New ApplicationException("No Database configured. Application will close!")
|
||||||
Application.Exit()
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -61,24 +59,42 @@ Public Class frmMain
|
|||||||
.Database = Database
|
.Database = Database
|
||||||
}
|
}
|
||||||
|
|
||||||
If Database.DBInitialized = True Then
|
If Database.DBInitialized = False Then
|
||||||
Dim ConfigModel = New ConfigModel(State)
|
Throw New ApplicationException("Could not connect to the database. Application will close!")
|
||||||
State.DbConfig = ConfigModel.LoadConfiguration()
|
End If
|
||||||
State.UserId = ConfigModel.GetUserId()
|
|
||||||
|
Dim ConfigModel = New ConfigModel(State)
|
||||||
|
State.DbConfig = ConfigModel.LoadConfiguration()
|
||||||
|
|
||||||
|
Dim oUserModel = New UserModel(State)
|
||||||
|
State.UserId = oUserModel.SelectUserId()
|
||||||
|
|
||||||
|
Dim oUser = oUserModel.SelectUser()
|
||||||
|
oUser = oUserModel.CheckUserLogin(oUser)
|
||||||
|
|
||||||
|
If oUser.HasAccess = False Then
|
||||||
|
Throw New ApplicationException("User is not activated for this module. Please contact your administrator. Application will close!")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Not String.IsNullOrEmpty(State.DbConfig.ExternalProgramName) Then
|
If Not String.IsNullOrEmpty(State.DbConfig.ExternalProgramName) Then
|
||||||
Me.Text = State.DbConfig.ExternalProgramName
|
Text = State.DbConfig.ExternalProgramName
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Controller = New EnvelopeListController(State)
|
Controller = New EnvelopeListController(State)
|
||||||
|
|
||||||
LoadEnvelopeData()
|
LoadEnvelopeData()
|
||||||
|
|
||||||
|
Catch ex As ApplicationException
|
||||||
|
Logger.Error(ex)
|
||||||
|
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
|
||||||
|
Application.Exit()
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Logger.Error(ex)
|
Logger.Error(ex)
|
||||||
End Try
|
MsgBox($"Unexpected error: {ex.Message}", MsgBoxStyle.Critical, Text)
|
||||||
|
Application.Exit()
|
||||||
|
|
||||||
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub LoadEnvelopeData()
|
Private Sub LoadEnvelopeData()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user