Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emiMobile
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mac Stephens
emiMobile
Commits
cf24b2b6
Commit
cf24b2b6
authored
Sep 04, 2026
by
emsys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugging
parent
76453efa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
66 deletions
+59
-66
Api.ServiceImpl.pas
emiMobileServer/Source/Api.ServiceImpl.pas
+3
-3
Auth.ServiceImpl.pas
emiMobileServer/Source/Auth.ServiceImpl.pas
+51
-51
emiMobileServer.dpr
emiMobileServer/emiMobileServer.dpr
+3
-1
emiMobileServer.dproj
emiMobileServer/emiMobileServer.dproj
+2
-11
No files found.
emiMobileServer/Source/Api.ServiceImpl.pas
View file @
cf24b2b6
unit
Api
.
ServiceImpl
;
unit
Api
.
ServiceImpl
;
interface
...
...
@@ -17,8 +17,8 @@ type
strict
private
ApiDB
:
TApiDatabaseModule
;
private
procedure
AfterConstruction
;
override
;
procedure
BeforeDestruction
;
override
;
//
procedure AfterConstruction; override;
//
procedure BeforeDestruction; override;
procedure
RequireAdmin
;
procedure
RequireActiveDevice
;
function
OpenLemsConnection
:
TUniConnection
;
...
...
emiMobileServer/Source/Auth.ServiceImpl.pas
View file @
cf24b2b6
unit
Auth
.
ServiceImpl
;
unit
Auth
.
ServiceImpl
;
interface
...
...
@@ -22,8 +22,8 @@ type
userId
:
string
;
userPersonnelId
:
string
;
userIsAdmin
:
Boolean
;
procedure
AfterConstruction
;
override
;
procedure
BeforeDestruction
;
override
;
//
procedure AfterConstruction; override;
//
procedure BeforeDestruction; override;
function
VerifyVersion
(
ClientVersion
:
string
):
TJSONObject
;
function
CheckUser
(
const
User
,
Password
,
Agency
:
string
):
Integer
;
function
Decrypt
(
inStr
,
keyStr
:
AnsiString
):
AnsiString
;
...
...
@@ -36,7 +36,7 @@ type
signature
:
string
):
string
;
constructor
Create
;
destructor
Destroy
;
override
;
function
Login
(
const
User
,
Password
,
Agency
:
string
):
string
;
//
function Login(const User, Password, Agency: string): string;
function
GetAgencieslist
():
TAgenciesList
;
function
GetAgencyConfiglist
:
TAgencyConfigList
;
function
BeginRegistration
(
const
PhoneNumber
:
string
):
TJSONObject
;
...
...
@@ -819,53 +819,53 @@ begin
end
;
end
;
function
TAuthService
.
Login
(
const
User
,
Password
,
Agency
:
string
):
string
;
var
userState
:
Integer
;
JWT
:
TJWT
;
begin
Logger
.
Log
(
1
,
Format
(
'AuthService.Login - User: "%s" Agency: "%s"'
,
[
User
,
Agency
]));
userState
:=
CheckUser
(
User
,
Password
,
Agency
);
try
userState
:=
CheckUser
(
User
,
Password
,
Agency
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'AuthService.Login - CheckUser error: '
+
E
.
ClassName
+
': '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Login failed'
);
end
;
end
;
if
userState
=
0
then
begin
Logger
.
Log
(
2
,
Format
(
'AuthService.Login - invalid login for User: "%s" Agency: "%s"'
,
[
User
,
Agency
]));
raise
EXDataHttpUnauthorized
.
Create
(
'Invalid user or password'
);
end
;
if
userState
=
1
then
begin
Logger
.
Log
(
2
,
Format
(
'AuthService.Login - inactive user: "%s" Agency: "%s"'
,
[
User
,
Agency
]));
raise
EXDataHttpUnauthorized
.
Create
(
'User not active'
);
end
;
JWT
:=
TJWT
.
Create
;
try
JWT
.
Claims
.
JWTId
:=
LowerCase
(
Copy
(
TUtils
.
GuidToVariant
(
TUtils
.
NewGuid
),
2
,
36
));
JWT
.
Claims
.
IssuedAt
:=
Now
;
JWT
.
Claims
.
Expiration
:=
IncHour
(
Now
,
24
);
JWT
.
Claims
.
SetClaimOfType
<
string
>(
'user_name'
,
userName
);
JWT
.
Claims
.
SetClaimOfType
<
string
>(
'user_fullname'
,
userFullName
);
JWT
.
Claims
.
SetClaimOfType
<
string
>(
'user_agency'
,
userAgency
);
JWT
.
Claims
.
SetClaimOfType
<
string
>(
'user_badge'
,
userBadge
);
JWT
.
Claims
.
SetClaimOfType
<
string
>(
'user_id'
,
userId
);
JWT
.
Claims
.
SetClaimOfType
<
string
>(
'user_personnelid'
,
userPersonnelId
);
Result
:=
TJOSE
.
SHA256CompactToken
(
ServerConfig
.
jwtTokenSecret
,
JWT
);
finally
JWT
.
Free
;
end
;
end
;
//
//
function TAuthService.Login(const User, Password, Agency: string): string;
//
var
//
userState: Integer;
//
JWT: TJWT;
//
begin
//
Logger.Log(1, Format('AuthService.Login - User: "%s" Agency: "%s"', [User, Agency]));
//
userState := CheckUser(User, Password, Agency);
//
//
try
//
userState := CheckUser(User, Password, Agency);
//
except
//
on E: Exception do
//
begin
//
Logger.Log(2, 'AuthService.Login - CheckUser error: ' + E.ClassName + ': ' + E.Message);
//
raise EXDataHttpException.Create(500, 'Login failed');
//
end;
//
end;
//
//
if userState = 0 then
//
begin
//
Logger.Log(2, Format('AuthService.Login - invalid login for User: "%s" Agency: "%s"', [User, Agency]));
//
raise EXDataHttpUnauthorized.Create('Invalid user or password');
//
end;
//
//
if userState = 1 then
//
begin
//
Logger.Log(2, Format('AuthService.Login - inactive user: "%s" Agency: "%s"', [User, Agency]));
//
raise EXDataHttpUnauthorized.Create('User not active');
//
end;
//
//
JWT := TJWT.Create;
//
try
//
JWT.Claims.JWTId := LowerCase(Copy(TUtils.GuidToVariant(TUtils.NewGuid), 2, 36));
//
JWT.Claims.IssuedAt := Now;
//
JWT.Claims.Expiration := IncHour(Now, 24);
//
JWT.Claims.SetClaimOfType<string>('user_name', userName);
//
JWT.Claims.SetClaimOfType<string>('user_fullname', userFullName);
//
JWT.Claims.SetClaimOfType<string>('user_agency', userAgency);
//
JWT.Claims.SetClaimOfType<string>('user_badge', userBadge);
//
JWT.Claims.SetClaimOfType<string>('user_id', userId);
//
JWT.Claims.SetClaimOfType<string>('user_personnelid', userPersonnelId);
//
Result := TJOSE.SHA256CompactToken(ServerConfig.jwtTokenSecret, JWT);
//
finally
//
JWT.Free;
//
end;
//
end;
function
TAuthService
.
CheckUser
(
const
User
,
Password
,
Agency
:
string
):
Integer
;
var
...
...
emiMobileServer/emiMobileServer.dpr
View file @
cf24b2b6
...
...
@@ -31,7 +31,9 @@ uses
Ws.Server.Module in 'Source\Ws.Server.Module.pas' {WsServerModule: TDataModule},
Ws.DataModel in 'Source\Ws.DataModel.pas',
WsMessages in 'Source\shared\WsMessages.pas',
WebSocket.Manager in 'Source\WebSocket.Manager.pas';
WebSocket.Manager in 'Source\WebSocket.Manager.pas',
Webauthn.Cbor in 'Source\Webauthn.Cbor.pas',
Webauthn.Crypto in 'Source\Webauthn.Crypto.pas';
type
TMemoLogAppender = class( TInterfacedObject, ILogAppender )
...
...
emiMobileServer/emiMobileServer.dproj
View file @
cf24b2b6
...
...
@@ -180,6 +180,8 @@
<DCCReference Include="Source\Ws.DataModel.pas"/>
<DCCReference Include="Source\shared\WsMessages.pas"/>
<DCCReference Include="Source\WebSocket.Manager.pas"/>
<DCCReference Include="Source\Webauthn.Cbor.pas"/>
<DCCReference Include="Source\Webauthn.Crypto.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
...
...
@@ -872,9 +874,6 @@
<Platform Name="Win64x">
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
...
...
@@ -945,10 +944,6 @@
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="UWP_DelphiLogo44">
<Platform Name="Win32">
...
...
@@ -959,10 +954,6 @@
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iOS_AppStore1024">
<Platform Name="iOSDevice64">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment