Commit cf24b2b6 by emsys

debugging

parent 76453efa
unit Api.ServiceImpl; unit Api.ServiceImpl;
interface interface
...@@ -17,8 +17,8 @@ type ...@@ -17,8 +17,8 @@ type
strict private strict private
ApiDB: TApiDatabaseModule; ApiDB: TApiDatabaseModule;
private private
procedure AfterConstruction; override; //procedure AfterConstruction; override;
procedure BeforeDestruction; override; //procedure BeforeDestruction; override;
procedure RequireAdmin; procedure RequireAdmin;
procedure RequireActiveDevice; procedure RequireActiveDevice;
function OpenLemsConnection: TUniConnection; function OpenLemsConnection: TUniConnection;
......
unit Auth.ServiceImpl; unit Auth.ServiceImpl;
interface interface
...@@ -22,8 +22,8 @@ type ...@@ -22,8 +22,8 @@ type
userId: string; userId: string;
userPersonnelId: string; userPersonnelId: string;
userIsAdmin: Boolean; userIsAdmin: Boolean;
procedure AfterConstruction; override; //procedure AfterConstruction; override;
procedure BeforeDestruction; override; //procedure BeforeDestruction; override;
function VerifyVersion(ClientVersion: string): TJSONObject; function VerifyVersion(ClientVersion: string): TJSONObject;
function CheckUser(const User, Password, Agency: string): Integer; function CheckUser(const User, Password, Agency: string): Integer;
function Decrypt(inStr, keyStr: AnsiString): AnsiString; function Decrypt(inStr, keyStr: AnsiString): AnsiString;
...@@ -36,7 +36,7 @@ type ...@@ -36,7 +36,7 @@ type
signature: string): string; signature: string): string;
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
function Login(const User, Password, Agency: string): string; //function Login(const User, Password, Agency: string): string;
function GetAgencieslist(): TAgenciesList; function GetAgencieslist(): TAgenciesList;
function GetAgencyConfiglist: TAgencyConfigList; function GetAgencyConfiglist: TAgencyConfigList;
function BeginRegistration(const PhoneNumber: string): TJSONObject; function BeginRegistration(const PhoneNumber: string): TJSONObject;
...@@ -819,53 +819,53 @@ begin ...@@ -819,53 +819,53 @@ begin
end; end;
end; end;
//
function TAuthService.Login(const User, Password, Agency: string): string; //function TAuthService.Login(const User, Password, Agency: string): string;
var //var
userState: Integer; // userState: Integer;
JWT: TJWT; // JWT: TJWT;
begin //begin
Logger.Log(1, Format('AuthService.Login - User: "%s" Agency: "%s"', [User, Agency])); // Logger.Log(1, Format('AuthService.Login - User: "%s" Agency: "%s"', [User, Agency]));
userState := CheckUser(User, Password, Agency); // userState := CheckUser(User, Password, Agency);
//
try // try
userState := CheckUser(User, Password, Agency); // userState := CheckUser(User, Password, Agency);
except // except
on E: Exception do // on E: Exception do
begin // begin
Logger.Log(2, 'AuthService.Login - CheckUser error: ' + E.ClassName + ': ' + E.Message); // Logger.Log(2, 'AuthService.Login - CheckUser error: ' + E.ClassName + ': ' + E.Message);
raise EXDataHttpException.Create(500, 'Login failed'); // raise EXDataHttpException.Create(500, 'Login failed');
end; // end;
end; // end;
//
if userState = 0 then // if userState = 0 then
begin // begin
Logger.Log(2, Format('AuthService.Login - invalid login for User: "%s" Agency: "%s"', [User, Agency])); // Logger.Log(2, Format('AuthService.Login - invalid login for User: "%s" Agency: "%s"', [User, Agency]));
raise EXDataHttpUnauthorized.Create('Invalid user or password'); // raise EXDataHttpUnauthorized.Create('Invalid user or password');
end; // end;
//
if userState = 1 then // if userState = 1 then
begin // begin
Logger.Log(2, Format('AuthService.Login - inactive user: "%s" Agency: "%s"', [User, Agency])); // Logger.Log(2, Format('AuthService.Login - inactive user: "%s" Agency: "%s"', [User, Agency]));
raise EXDataHttpUnauthorized.Create('User not active'); // raise EXDataHttpUnauthorized.Create('User not active');
end; // end;
//
JWT := TJWT.Create; // JWT := TJWT.Create;
try // try
JWT.Claims.JWTId := LowerCase(Copy(TUtils.GuidToVariant(TUtils.NewGuid), 2, 36)); // JWT.Claims.JWTId := LowerCase(Copy(TUtils.GuidToVariant(TUtils.NewGuid), 2, 36));
JWT.Claims.IssuedAt := Now; // JWT.Claims.IssuedAt := Now;
JWT.Claims.Expiration := IncHour(Now, 24); // JWT.Claims.Expiration := IncHour(Now, 24);
JWT.Claims.SetClaimOfType<string>('user_name', userName); // JWT.Claims.SetClaimOfType<string>('user_name', userName);
JWT.Claims.SetClaimOfType<string>('user_fullname', userFullName); // JWT.Claims.SetClaimOfType<string>('user_fullname', userFullName);
JWT.Claims.SetClaimOfType<string>('user_agency', userAgency); // JWT.Claims.SetClaimOfType<string>('user_agency', userAgency);
JWT.Claims.SetClaimOfType<string>('user_badge', userBadge); // JWT.Claims.SetClaimOfType<string>('user_badge', userBadge);
JWT.Claims.SetClaimOfType<string>('user_id', userId); // JWT.Claims.SetClaimOfType<string>('user_id', userId);
JWT.Claims.SetClaimOfType<string>('user_personnelid', userPersonnelId); // JWT.Claims.SetClaimOfType<string>('user_personnelid', userPersonnelId);
Result := TJOSE.SHA256CompactToken(ServerConfig.jwtTokenSecret, JWT); // Result := TJOSE.SHA256CompactToken(ServerConfig.jwtTokenSecret, JWT);
finally // finally
JWT.Free; // JWT.Free;
end; // end;
end; //end;
function TAuthService.CheckUser(const User, Password, Agency: string): Integer; function TAuthService.CheckUser(const User, Password, Agency: string): Integer;
var var
......
...@@ -31,7 +31,9 @@ uses ...@@ -31,7 +31,9 @@ uses
Ws.Server.Module in 'Source\Ws.Server.Module.pas' {WsServerModule: TDataModule}, Ws.Server.Module in 'Source\Ws.Server.Module.pas' {WsServerModule: TDataModule},
Ws.DataModel in 'Source\Ws.DataModel.pas', Ws.DataModel in 'Source\Ws.DataModel.pas',
WsMessages in 'Source\shared\WsMessages.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 type
TMemoLogAppender = class( TInterfacedObject, ILogAppender ) TMemoLogAppender = class( TInterfacedObject, ILogAppender )
......
...@@ -180,6 +180,8 @@ ...@@ -180,6 +180,8 @@
<DCCReference Include="Source\Ws.DataModel.pas"/> <DCCReference Include="Source\Ws.DataModel.pas"/>
<DCCReference Include="Source\shared\WsMessages.pas"/> <DCCReference Include="Source\shared\WsMessages.pas"/>
<DCCReference Include="Source\WebSocket.Manager.pas"/> <DCCReference Include="Source\WebSocket.Manager.pas"/>
<DCCReference Include="Source\Webauthn.Cbor.pas"/>
<DCCReference Include="Source\Webauthn.Crypto.pas"/>
<BuildConfiguration Include="Base"> <BuildConfiguration Include="Base">
<Key>Base</Key> <Key>Base</Key>
</BuildConfiguration> </BuildConfiguration>
...@@ -872,9 +874,6 @@ ...@@ -872,9 +874,6 @@
<Platform Name="Win64x"> <Platform Name="Win64x">
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="WinARM64EC">
<Operation>1</Operation>
</Platform>
</DeployClass> </DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug"> <DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32"> <Platform Name="iOSDevice32">
...@@ -945,10 +944,6 @@ ...@@ -945,10 +944,6 @@
<RemoteDir>Assets</RemoteDir> <RemoteDir>Assets</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass> </DeployClass>
<DeployClass Name="UWP_DelphiLogo44"> <DeployClass Name="UWP_DelphiLogo44">
<Platform Name="Win32"> <Platform Name="Win32">
...@@ -959,10 +954,6 @@ ...@@ -959,10 +954,6 @@
<RemoteDir>Assets</RemoteDir> <RemoteDir>Assets</RemoteDir>
<Operation>1</Operation> <Operation>1</Operation>
</Platform> </Platform>
<Platform Name="WinARM64EC">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass> </DeployClass>
<DeployClass Name="iOS_AppStore1024"> <DeployClass Name="iOS_AppStore1024">
<Platform Name="iOSDevice64"> <Platform Name="iOSDevice64">
......
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