// Auth Database to verify logins

unit Auth.Database;

interface

uses
  System.SysUtils, System.Classes, IniFiles, Vcl.Forms, MemDS,
  Data.DB, DBAccess, Uni, UniProvider, PostgreSQLUniProvider, MySQLUniProvider;

type
  TAuthDatabase = class(TDataModule)
    uqWebTasksUrl: TUniQuery;
    ucETaskAuth: TUniConnection;
    MySQLUniProvider1: TMySQLUniProvider;
    uqWebTasksUrlUSER_ID: TStringField;
    uqWebTasksUrlUSER_NAME: TStringField;
    uqWebTasksUrlNAME: TStringField;
    uqWebTasksUrlSTATUS: TStringField;
    uqWebTasksUrlEMAIL: TStringField;
    uqWebTasksUrlACCESS_LEVEL: TIntegerField;
    uqWebTasksUrlTASK_RIGHTS: TIntegerField;
    uqWebTasksUrlPERSPECTIVE_ID: TStringField;
    uqWebTasksUrlLAST_NAME: TStringField;
    uqWebTasksUrlFIRST_NAME: TStringField;
    uqWebTasksUrlURL_TIME: TDateTimeField;
    uqWebTasksUrlURL_TIME_EXP: TIntegerField;
    uqWebLogin: TUniQuery;
    uqWebLoginUSER_ID: TStringField;
    uqWebLoginUSER_NAME: TStringField;
    uqWebLoginNAME: TStringField;
    uqWebLoginSTATUS: TStringField;
    uqWebLoginEMAIL: TStringField;
    uqWebLoginACCESS_LEVEL: TIntegerField;
    uqWebLoginTASK_RIGHTS: TIntegerField;
    uqWebLoginPERSPECTIVE_ID: TStringField;
    uqWebLoginLAST_NAME: TStringField;
    uqWebLoginFIRST_NAME: TStringField;
    uqWebLoginPASSWORD: TStringField;
    uqWebLoginWEB_LOGIN: TStringField;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  AuthDatabase: TAuthDatabase;

implementation

uses
  System.JSON,
  Common.Config,
  Common.Logging,
  uLibrary;

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

procedure TAuthDatabase.DataModuleCreate(Sender: TObject);
begin
  Logger.Log( 5, 'TAuthDatabase.DataModuleCreate' );
  LoadDatabaseSettings( ucETaskAuth, 'emT3XDataServer.ini' );
  try
    ucETaskAuth.Connect;
  except
    on E: Exception do
    begin
      Logger.Log(2, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
    end;
  end;
end;

procedure TAuthDatabase.DataModuleDestroy(Sender: TObject);
begin
  ucETaskAuth.Connected := false;
end;


end.
