Commit 9824e397 by Cam Hayes

Changed EditUser form, fixed memory leak issues, and fixed issue with database…

Changed EditUser form, fixed memory leak issues, and fixed issue with database files crashing on create
parent 59c3c0cc
...@@ -3,8 +3,8 @@ object FViewEditUser: TFViewEditUser ...@@ -3,8 +3,8 @@ object FViewEditUser: TFViewEditUser
Height = 480 Height = 480
OnShow = WebFormCreate OnShow = WebFormCreate
object WebLabel2: TWebLabel object WebLabel2: TWebLabel
Left = 16 Left = 33
Top = 8 Top = 33
Width = 57 Width = 57
Height = 15 Height = 15
Caption = 'Full Name:' Caption = 'Full Name:'
...@@ -14,8 +14,8 @@ object FViewEditUser: TFViewEditUser ...@@ -14,8 +14,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebLabel3: TWebLabel object WebLabel3: TWebLabel
Left = 14 Left = 283
Top = 37 Top = 8
Width = 53 Width = 53
Height = 15 Height = 15
Caption = 'Password:' Caption = 'Password:'
...@@ -25,7 +25,7 @@ object FViewEditUser: TFViewEditUser ...@@ -25,7 +25,7 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebLabel5: TWebLabel object WebLabel5: TWebLabel
Left = 280 Left = 34
Top = 8 Top = 8
Width = 56 Width = 56
Height = 15 Height = 15
...@@ -35,19 +35,8 @@ object FViewEditUser: TFViewEditUser ...@@ -35,19 +35,8 @@ object FViewEditUser: TFViewEditUser
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebLabel6: TWebLabel
Left = 236
Top = 37
Width = 100
Height = 15
Caption = 'Confirm Password:'
Color = clBtnFace
ElementID = 'lblconfirm'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel7: TWebLabel object WebLabel7: TWebLabel
Left = 35 Left = 58
Top = 62 Top = 62
Width = 32 Width = 32
Height = 15 Height = 15
...@@ -58,8 +47,8 @@ object FViewEditUser: TFViewEditUser ...@@ -58,8 +47,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object lblactive: TWebLabel object lblactive: TWebLabel
Left = 45 Left = 298
Top = 163 Top = 36
Width = 38 Width = 38
Height = 15 Height = 15
Caption = 'Active?' Caption = 'Active?'
...@@ -99,17 +88,6 @@ object FViewEditUser: TFViewEditUser ...@@ -99,17 +88,6 @@ object FViewEditUser: TFViewEditUser
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object edtConfirmPassword: TWebEdit
Left = 346
Top = 34
Width = 121
Height = 22
ChildOrder = 7
ElementID = 'edtconfirmpassword'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtConfirmPasswordChange
end
object edtEmail: TWebEdit object edtEmail: TWebEdit
Left = 96 Left = 96
Top = 62 Top = 62
...@@ -129,7 +107,6 @@ object FViewEditUser: TFViewEditUser ...@@ -129,7 +107,6 @@ object FViewEditUser: TFViewEditUser
ElementID = 'edtpassword' ElementID = 'edtpassword'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnChange = edtPasswordChange
end end
object btnConfirm: TWebButton object btnConfirm: TWebButton
Left = 96 Left = 96
...@@ -151,8 +128,8 @@ object FViewEditUser: TFViewEditUser ...@@ -151,8 +128,8 @@ object FViewEditUser: TFViewEditUser
OnClick = btnConfirmClick OnClick = btnConfirmClick
end end
object edtFullname: TWebEdit object edtFullname: TWebEdit
Left = 96 Left = 346
Top = 4 Top = 5
Width = 121 Width = 121
Height = 22 Height = 22
ChildOrder = 14 ChildOrder = 14
...@@ -161,8 +138,8 @@ object FViewEditUser: TFViewEditUser ...@@ -161,8 +138,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object edtUsername: TWebEdit object edtUsername: TWebEdit
Left = 346 Left = 96
Top = 4 Top = 6
Width = 121 Width = 121
Height = 22 Height = 22
ChildOrder = 14 ChildOrder = 14
...@@ -190,8 +167,8 @@ object FViewEditUser: TFViewEditUser ...@@ -190,8 +167,8 @@ object FViewEditUser: TFViewEditUser
OnClick = btnCancelClick OnClick = btnCancelClick
end end
object cbStatus: TWebCheckBox object cbStatus: TWebCheckBox
Left = 96 Left = 346
Top = 162 Top = 33
Width = 107 Width = 107
Height = 20 Height = 20
Caption = 'Active?' Caption = 'Active?'
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
<form id="edituserform" class="row g-3 needs-validation" novalidate> <form id="edituserform" class="row g-3 needs-validation" novalidate>
<div class="col-md-6"> <div class="col-md-6">
<label id="lblfullname" for="edtfullname" class="form-label">Full&nbsp;Name</label>
<input id="edtfullname" class="form-control" required>
<div class="invalid-feedback">Full Name is required.</div>
</div>
<div class="col-md-6">
<label id="lblusername" for="edtusername" class="form-label">Username</label> <label id="lblusername" for="edtusername" class="form-label">Username</label>
<input id="edtusername" class="form-control" required> <input id="edtusername" class="form-control" required>
<div class="invalid-feedback">Username is required.</div> <div class="invalid-feedback">Username is required.</div>
...@@ -20,19 +14,26 @@ ...@@ -20,19 +14,26 @@
<div class="col-md-6"> <div class="col-md-6">
<label id="lblpassword" for="edtpassword" class="form-label">Password</label> <label id="lblpassword" for="edtpassword" class="form-label">Password</label>
<input id="edtpassword" type="password" class="form-control" required> <input id="edtpassword" type="password" class="form-control" required>
<div class="invalid-feedback">Passwords must match.</div> <div class="invalid-feedback">Passwords is required.</div>
</div>
<div class="col-md-6">
<label id="lblfullname" for="edtfullname" class="form-label">Full&nbsp;Name</label>
<input id="edtfullname" class="form-control" required>
<div class="invalid-feedback">Full Name is required.</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label id="lblconfirm" for="edtconfirmpassword" class="form-label">Confirm&nbsp;Password</label> <label id="lblactive" for="cbstatus" class="form-label">Active</label>
<input id="edtconfirmpassword" type="password" class="form-control" required disabled> <div class="form-check mt-1">
<div class="invalid-feedback">Passwords must match.</div> <input id="cbstatus" class="form-check-input" type="checkbox" style="width: 1.5em; height: 1.5em;">
</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label id="lblemail" for="edtemail" class="form-label">Email&nbsp;Address</label> <label id="lblemail" for="edtemail" class="form-label">Email&nbsp;Address</label>
<input id="edtemail" type="email" class="form-control" required> <input id="edtemail" type="email" class="form-control">
<div class="invalid-feedback">Valid email is required.</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
...@@ -47,19 +48,8 @@ ...@@ -47,19 +48,8 @@
<div class="col-md-6"> <div class="col-md-6">
<label id="lblaccess" for="cbaccess" class="form-label">Access&nbsp;Type</label> <label id="lblaccess" for="cbaccess" class="form-label">Access&nbsp;Type</label>
<select id="cbaccess" class="form-select" required> <select id="cbaccess" class="form-select">
<option selected disabled value="">Choose...</option>
<option value="ALL">All</option>
<option value="LIMITED">Limited</option>
</select> </select>
<div class="invalid-feedback">Please select an access type.</div>
</div>
<div class="col-md-6">
<div class="form-check pt-2">
<input id="cbstatus" class="form-check-input" type="checkbox">
<label id="lblactive" for="cbstatus" class="form-check-label">Active</label>
</div>
</div> </div>
<div class="d-flex gap-2 mt-4"> <div class="d-flex gap-2 mt-4">
......
...@@ -15,9 +15,7 @@ type ...@@ -15,9 +15,7 @@ type
WebLabel2: TWebLabel; WebLabel2: TWebLabel;
WebLabel3: TWebLabel; WebLabel3: TWebLabel;
WebLabel5: TWebLabel; WebLabel5: TWebLabel;
WebLabel6: TWebLabel;
WebLabel7: TWebLabel; WebLabel7: TWebLabel;
edtConfirmPassword: TWebEdit;
edtEmail: TWebEdit; edtEmail: TWebEdit;
edtPassword: TWebEdit; edtPassword: TWebEdit;
btnConfirm: TWebButton; btnConfirm: TWebButton;
...@@ -38,8 +36,6 @@ type ...@@ -38,8 +36,6 @@ type
procedure btnConfirmClick(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure WebTimer1Timer(Sender: TObject); procedure WebTimer1Timer(Sender: TObject);
procedure edtPasswordChange(Sender: TObject);
procedure edtConfirmPasswordChange(Sender: TObject);
private private
{ Private declarations } { Private declarations }
FMessage: string; FMessage: string;
...@@ -54,7 +50,6 @@ type ...@@ -54,7 +50,6 @@ type
QB: string; QB: string;
[async] procedure EditUser(); [async] procedure EditUser();
[async] function AddUser(): string; [async] function AddUser(): string;
procedure ValidatePasswords;
public public
{ Public declarations } { Public declarations }
Info: string; Info: string;
...@@ -138,16 +133,6 @@ begin ...@@ -138,16 +133,6 @@ begin
end; end;
procedure TFViewEditUser.edtConfirmPasswordChange(Sender: TObject);
begin
ValidatePasswords;
end;
procedure TFViewEditUser.edtPasswordChange(Sender: TObject);
begin
ValidatePasswords;
end;
class function TFViewEditUser.CreateForm(AElementID, Mode, Username, Password, Name, Status, Email, class function TFViewEditUser.CreateForm(AElementID, Mode, Username, Password, Name, Status, Email,
Access, Rights, QB: string): TWebForm; Access, Rights, QB: string): TWebForm;
// Autofills known information about a user on create // Autofills known information about a user on create
...@@ -180,7 +165,6 @@ begin ...@@ -180,7 +165,6 @@ begin
if Mode = 'Edit' then if Mode = 'Edit' then
begin begin
edtPassword.Text := 'hidden'; edtPassword.Text := 'hidden';
edtConfirmPassword.Text := 'hidden';
end; end;
edtEmail.Text := Email; edtEmail.Text := Email;
cbAccess.Text := Access; cbAccess.Text := Access;
...@@ -226,52 +210,4 @@ begin ...@@ -226,52 +210,4 @@ begin
WebTimer1.Enabled := True; WebTimer1.Enabled := True;
end; end;
procedure TFViewEditUser.ValidatePasswords;
var
Pwd, Confirm: string;
PwdInput, ConfirmInput: TJSHTMLInputElement;
begin
PwdInput := TJSHTMLInputElement(edtPassword.ElementHandle);
ConfirmInput := TJSHTMLInputElement(edtConfirmPassword.ElementHandle);
Pwd := PwdInput.value.Trim;
Confirm := ConfirmInput.value.Trim;
// Disable confirm until password exists
if Pwd = '' then
begin
ConfirmInput.disabled := True;
ConfirmInput.value := '';
ConfirmInput.setCustomValidity('');
ConfirmInput.classList.remove('is-invalid');
ConfirmInput.classList.remove('is-valid');
end
else
begin
ConfirmInput.disabled := False;
// Live match check
if Confirm = '' then
begin
ConfirmInput.setCustomValidity('');
ConfirmInput.classList.remove('is-invalid');
ConfirmInput.classList.remove('is-valid');
end
else if Confirm = Pwd then
begin
ConfirmInput.setCustomValidity('');
ConfirmInput.classList.add('is-valid');
ConfirmInput.classList.remove('is-invalid');
end
else
begin
ConfirmInput.setCustomValidity('Passwords must match');
ConfirmInput.classList.add('is-invalid');
ConfirmInput.classList.remove('is-valid');
end;
end;
end;
end. end.
...@@ -6,8 +6,6 @@ object ApiDatabase: TApiDatabase ...@@ -6,8 +6,6 @@ object ApiDatabase: TApiDatabase
ProviderName = 'MySQL' ProviderName = 'MySQL'
Database = 'kg_order_entry' Database = 'kg_order_entry'
Username = 'root' Username = 'root'
Server = '192.168.159.10'
Connected = True
LoginPrompt = False LoginPrompt = False
Left = 75 Left = 75
Top = 65 Top = 65
......
...@@ -55,7 +55,15 @@ uses ...@@ -55,7 +55,15 @@ uses
procedure TAuthService.AfterConstruction; procedure TAuthService.AfterConstruction;
begin begin
inherited; inherited;
authDB := TAuthDatabase.Create(nil); try
authDB := TAuthDatabase.Create(nil);
except
on E: Exception do
begin
Logger.Log(1, 'Error when creating the Auth database: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to create Auth database: A KGOrders Server Error has occured!');
end;
end;
end; end;
procedure TAuthService.BeforeDestruction; procedure TAuthService.BeforeDestruction;
...@@ -130,8 +138,10 @@ begin ...@@ -130,8 +138,10 @@ begin
logger.Log(2, 'Login Error: User does not exist!'); logger.Log(2, 'Login Error: User does not exist!');
end end
else if userState = 2 then else if userState = 2 then
begin
raise EXDataHttpUnauthorized.Create('User not active!'); raise EXDataHttpUnauthorized.Create('User not active!');
logger.Log(2, 'Login Error: User not active!'); logger.Log(2, 'Login Error: User not active!');
end;
iniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini')); iniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
MemoLogLevel=4 MemoLogLevel=4
FileLogLevel=4 FileLogLevel=4
webClientVersion=1.0.0 webClientVersion=1.0.0
LogFileNum=141 LogFileNum=157
[Database] [Database]
--Server=192.168.116.138 --Server=192.168.116.138
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment