check user login

This commit is contained in:
Jonathan Jenne
2023-12-07 09:35:23 +01:00
parent 1108fa47e0
commit cd23c5b974
4 changed files with 62 additions and 17 deletions

View File

@@ -44,9 +44,7 @@ Public Class frmMain
ConfigManager.Save()
Application.Restart()
Else
FormHelper.ShowErrorMessage(New ApplicationException("No Database configured. Application will close!"), "Form Load")
Application.Exit()
Throw New ApplicationException("No Database configured. Application will close!")
End If
End If
@@ -61,24 +59,42 @@ Public Class frmMain
.Database = Database
}
If Database.DBInitialized = True Then
Dim ConfigModel = New ConfigModel(State)
State.DbConfig = ConfigModel.LoadConfiguration()
State.UserId = ConfigModel.GetUserId()
If Database.DBInitialized = False Then
Throw New ApplicationException("Could not connect to the database. Application will close!")
End If
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
If Not String.IsNullOrEmpty(State.DbConfig.ExternalProgramName) Then
Me.Text = State.DbConfig.ExternalProgramName
Text = State.DbConfig.ExternalProgramName
End If
Controller = New EnvelopeListController(State)
LoadEnvelopeData()
Catch ex As ApplicationException
Logger.Error(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
Application.Exit()
Catch ex As Exception
Logger.Error(ex)
End Try
MsgBox($"Unexpected error: {ex.Message}", MsgBoxStyle.Critical, Text)
Application.Exit()
End Try
End Sub
Private Sub LoadEnvelopeData()