Tarea #347 -> Quitar login de usuario y contraseña al iniciar el programa

git-svn-id: https://192.168.0.254/svn/Proyectos.Noviseda_FactuGES2/trunk@89 f33bb606-9f5c-448d-9c99-757f00063c96
This commit is contained in:
David Arranz 2010-02-09 16:58:33 +00:00
parent d14500b028
commit 62a8440a92
6 changed files with 82 additions and 15 deletions

View File

@ -14,7 +14,7 @@ type
['{DD963EEC-5880-4DE7-AF55-B5080B538D84}'] ['{DD963EEC-5880-4DE7-AF55-B5080B538D84}']
procedure Logoff; procedure Logoff;
function StartLogin : Boolean; function StartLogin (const AUsuario : String = ''; const APassword : String = ''): Boolean;
procedure VerUsuarios; procedure VerUsuarios;
procedure VerPerfiles; procedure VerPerfiles;
procedure VerUsuario(const AIDUser: Integer); overload; procedure VerUsuario(const AIDUser: Integer); overload;
@ -121,7 +121,7 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure Logoff; procedure Logoff;
function StartLogin : Boolean; function StartLogin (const AUsuario : String = ''; const APassword : String = ''): Boolean;
procedure VerUsuarios; procedure VerUsuarios;
procedure VerPerfiles; procedure VerPerfiles;
@ -174,7 +174,7 @@ uses
uDAInterfaces, uDataTableUtils, uDialogUtils, uFactuGES_App, Dialogs, uDAInterfaces, uDataTableUtils, uDialogUtils, uFactuGES_App, Dialogs,
uDateUtils, uROTypes, DateUtils, Controls, Windows, uIEditorLogin, uDateUtils, uROTypes, DateUtils, Controls, Windows, uIEditorLogin,
uIEditorUsuarios, uIEditorUsuario, uIEditorPerfilesUsuario, uIEditorUsuarios, uIEditorUsuario, uIEditorPerfilesUsuario,
uIEditorPerfilUsuario, uEditorCambiarPassword; uIEditorPerfilUsuario, uEditorCambiarPassword, uStringsUtils;
{ TUsuariosController } { TUsuariosController }
@ -856,22 +856,39 @@ begin
FUserControl.ShowUserManager; FUserControl.ShowUserManager;
end; end;
function TUsuariosController.StartLogin : Boolean; function TUsuariosController.StartLogin (const AUsuario : String = '';
const APassword : String = ''): Boolean;
var var
AEditor : IEditorLogin; AEditor : IEditorLogin;
begin begin
Result := False; Result := False;
AEditor := NIL; AEditor := NIL;
CreateEditor('EditorLogin', IEditorLogin, AEditor); // Intentamos un login automático si hay datos en los parámetros
if Assigned(AEditor) then if not EsCadenaVacia(AUsuario) and not EsCadenaVacia(APassword) then
begin
ShowHourglassCursor;
try try
AEditor.Controller := Self; Result := ComprobarUsuario(AUsuario, APassword);
Result := (AEditor.ShowModal = mrOk);
finally finally
AEditor.Release; HideHourglassCursor;
AEditor := NIL;
end; end;
end;
{ Si los parámetros están vacíos o ComprobarUsuario ha fallado,
mostrar la pantalla de login }
if not Result then
begin
CreateEditor('EditorLogin', IEditorLogin, AEditor);
if Assigned(AEditor) then
try
AEditor.Controller := Self;
Result := (AEditor.ShowModal = mrOk);
finally
AEditor.Release;
AEditor := NIL;
end;
end;
end; end;
procedure TUsuariosController.FiltrarEmpresa(AUsuario: IBizUsuario); procedure TUsuariosController.FiltrarEmpresa(AUsuario: IBizUsuario);

View File

@ -8,6 +8,7 @@ uses
type type
TAppFactuGES_Event = procedure; TAppFactuGES_Event = procedure;
TOnBeforeStartLogin_Event = procedure(var ANombreUsuario: String; var APassword: String);
IAppSplashForm = interface IAppSplashForm = interface
['{9905DF57-4476-42E6-A7CD-B1479A84E220}'] ['{9905DF57-4476-42E6-A7CD-B1479A84E220}']
@ -32,6 +33,9 @@ type
function GetModuleManager : THostManager; function GetModuleManager : THostManager;
function GetTerminated: Boolean; function GetTerminated: Boolean;
function GetOnBeforeStartLogin : TOnBeforeStartLogin_Event;
procedure SetOnBeforeStartLogin (AOnBeforeStartLogin : TOnBeforeStartLogin_Event);
function GetLoadModulesEvent : TAppFactuGES_Event; function GetLoadModulesEvent : TAppFactuGES_Event;
procedure SetLoadModulesEvent (ALoadModulesEvent : TAppFactuGES_Event); procedure SetLoadModulesEvent (ALoadModulesEvent : TAppFactuGES_Event);
@ -68,6 +72,7 @@ type
property DoMainFormEvent : TAppFactuGES_Event read GetDoMainFormEvent write SetDoMainFormEvent; property DoMainFormEvent : TAppFactuGES_Event read GetDoMainFormEvent write SetDoMainFormEvent;
property DoLoadModulesEvent : TAppFactuGES_Event read GetLoadModulesEvent write SetLoadModulesEvent; property DoLoadModulesEvent : TAppFactuGES_Event read GetLoadModulesEvent write SetLoadModulesEvent;
property DoRefreshMainFormEvent : TAppFactuGES_Event read GetDoRefreshMainFormEvent write SetDoRefreshMainFormEvent; property DoRefreshMainFormEvent : TAppFactuGES_Event read GetDoRefreshMainFormEvent write SetDoRefreshMainFormEvent;
property OnBeforeStartLogin : TOnBeforeStartLogin_Event read GetOnBeforeStartLogin write SetOnBeforeStartLogin;
property Terminated : Boolean read GetTerminated; property Terminated : Boolean read GetTerminated;
end; end;
@ -84,6 +89,7 @@ type
FDoMainFormEvent: TAppFactuGES_Event; FDoMainFormEvent: TAppFactuGES_Event;
FDoLoadModulesEvent: TAppFactuGES_Event; FDoLoadModulesEvent: TAppFactuGES_Event;
FDoRefreshMainFormEvent: TAppFactuGES_Event; FDoRefreshMainFormEvent: TAppFactuGES_Event;
FOnBeforeStartLogin : TOnBeforeStartLogin_Event;
function GetMainForm: TCustomForm; function GetMainForm: TCustomForm;
function GetEmpresasController: IEmpresasController; function GetEmpresasController: IEmpresasController;
@ -108,11 +114,16 @@ type
function GetAppSplashForm : IAppSplashForm; function GetAppSplashForm : IAppSplashForm;
procedure SetAppSplashForm (AAppSplashForm : IAppSplashForm); procedure SetAppSplashForm (AAppSplashForm : IAppSplashForm);
function GetOnBeforeStartLogin : TOnBeforeStartLogin_Event;
procedure SetOnBeforeStartLogin (AOnBeforeStartLogin : TOnBeforeStartLogin_Event);
procedure AfterLoadModule(Sender: TObject; AModuleInfo: TModuleInfo); procedure AfterLoadModule(Sender: TObject; AModuleInfo: TModuleInfo);
procedure RegisterModule(AModuleInfo : TModuleInfo); procedure RegisterModule(AModuleInfo : TModuleInfo);
procedure SetOnBeforesStartLogin(const Value: TOnBeforeStartLogin_Event);
protected protected
procedure DoMainForm; procedure DoMainForm;
procedure DoRefreshMainForm; procedure DoRefreshMainForm;
function DoLogin: Boolean;
procedure CargarModulos; procedure CargarModulos;
procedure ShowSplashForm; procedure ShowSplashForm;
@ -144,6 +155,7 @@ type
property DoLoadModulesEvent : TAppFactuGES_Event read GetLoadModulesEvent write SetLoadModulesEvent; property DoLoadModulesEvent : TAppFactuGES_Event read GetLoadModulesEvent write SetLoadModulesEvent;
property DoRefreshMainFormEvent : TAppFactuGES_Event read GetDoRefreshMainFormEvent write SetDoRefreshMainFormEvent; property DoRefreshMainFormEvent : TAppFactuGES_Event read GetDoRefreshMainFormEvent write SetDoRefreshMainFormEvent;
property Terminated : Boolean read GetTerminated; property Terminated : Boolean read GetTerminated;
property OnBeforeStartLogin : TOnBeforeStartLogin_Event read GetOnBeforeStartLogin write SetOnBeforesStartLogin;
end; end;
var var
@ -216,6 +228,20 @@ begin
inherited; inherited;
end; end;
function TAppFactuGES.DoLogin: Boolean;
var
AUsuario,
APassword : String;
begin
AUsuario := '';
APassword := '';
if Assigned(FOnBeforeStartLogin) then
FOnBeforeStartLogin(AUsuario, APassword);
Result := UsuariosController.StartLogin(AUsuario, APassword);
end;
procedure TAppFactuGES.DoMainForm; procedure TAppFactuGES.DoMainForm;
begin begin
if not Assigned(FDoMainFormEvent) then if not Assigned(FDoMainFormEvent) then
@ -292,6 +318,11 @@ begin
Result := FHostManager; Result := FHostManager;
end; end;
function TAppFactuGES.GetOnBeforeStartLogin: TOnBeforeStartLogin_Event;
begin
Result := FOnBeforeStartLogin;
end;
function TAppFactuGES.GetTerminated: Boolean; function TAppFactuGES.GetTerminated: Boolean;
begin begin
Result := FTerminated; Result := FTerminated;
@ -339,7 +370,7 @@ end;
procedure TAppFactuGES.Run; procedure TAppFactuGES.Run;
begin begin
if UsuariosController.StartLogin then if DoLogin then
begin begin
ShowHourglassCursor; ShowHourglassCursor;
ShowSplashForm; ShowSplashForm;
@ -427,6 +458,18 @@ begin
FDoLoadModulesEvent := ALoadModulesEvent; FDoLoadModulesEvent := ALoadModulesEvent;
end; end;
procedure TAppFactuGES.SetOnBeforesStartLogin(
const Value: TOnBeforeStartLogin_Event);
begin
end;
procedure TAppFactuGES.SetOnBeforeStartLogin(
AOnBeforeStartLogin: TOnBeforeStartLogin_Event);
begin
FOnBeforeStartLogin := AOnBeforeStartLogin;
end;
procedure TAppFactuGES.ShowSplashForm; procedure TAppFactuGES.ShowSplashForm;
begin begin
if not Assigned(FAppSplashForm) then if not Assigned(FAppSplashForm) then

View File

@ -1,6 +1,7 @@
program FactuGES; program FactuGES;
uses uses
ExceptionLog,
Forms, Forms,
Windows, Windows,
SysUtils, SysUtils,

View File

@ -48,6 +48,7 @@
<DCC_DebugInfoInExe>True</DCC_DebugInfoInExe> <DCC_DebugInfoInExe>True</DCC_DebugInfoInExe>
<DCC_DebugVN>True</DCC_DebugVN> <DCC_DebugVN>True</DCC_DebugVN>
<DCC_SymbolReferenceInfo>2</DCC_SymbolReferenceInfo> <DCC_SymbolReferenceInfo>2</DCC_SymbolReferenceInfo>
<DCC_Define>EUREKALOG;EUREKALOG_VER6</DCC_Define>
</PropertyGroup> </PropertyGroup>
<ProjectExtensions> <ProjectExtensions>
<Borland.Personality>Delphi.Personality</Borland.Personality> <Borland.Personality>Delphi.Personality</Borland.Personality>
@ -79,7 +80,7 @@
<!-- EurekaLog First Line <!-- EurekaLog First Line
[Exception Log] [Exception Log]
EurekaLog Version=6011 EurekaLog Version=6011
Activate=0 Activate=1
Activate Handle=1 Activate Handle=1
Save Log File=1 Save Log File=1
Foreground Tab=0 Foreground Tab=0

View File

@ -66,6 +66,12 @@ begin
Application.CreateForm(TfPantallaPrincipal, fPantallaPrincipal); Application.CreateForm(TfPantallaPrincipal, fPantallaPrincipal);
end; end;
procedure BeforeStartLogin(var ANombreUsuario: String; var APassword: String);
begin
ANombreUsuario := 'admin';
APassword := '1';
end;
procedure Initialize; procedure Initialize;
begin begin
dmConexion := TdmConexion.Create(NIL); dmConexion := TdmConexion.Create(NIL);
@ -79,6 +85,7 @@ begin
DoMainFormEvent := DoAppMainForm; DoMainFormEvent := DoAppMainForm;
DoLoadModulesEvent := DoAppLoadModules; DoLoadModulesEvent := DoAppLoadModules;
DoRefreshMainFormEvent := DoRefreshMainForm; DoRefreshMainFormEvent := DoRefreshMainForm;
OnBeforeStartLogin := BeforeStartLogin;
end; end;
NavPaneController := TNavPaneController.Create; NavPaneController := TNavPaneController.Create;

View File

@ -180,8 +180,6 @@ begin
ApplicationEvents.Activate; ApplicationEvents.Activate;
Application.Title := AppFactuGES.AppName + ' ' + AppFactuGES.AppVersion; Application.Title := AppFactuGES.AppName + ' ' + AppFactuGES.AppVersion;
Caption := Application.Title; Caption := Application.Title;
actLogin.Execute;
end; end;
procedure TfPantallaPrincipal.FormShow(Sender: TObject); procedure TfPantallaPrincipal.FormShow(Sender: TObject);