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}']
procedure Logoff;
function StartLogin : Boolean;
function StartLogin (const AUsuario : String = ''; const APassword : String = ''): Boolean;
procedure VerUsuarios;
procedure VerPerfiles;
procedure VerUsuario(const AIDUser: Integer); overload;
@ -121,7 +121,7 @@ type
destructor Destroy; override;
procedure Logoff;
function StartLogin : Boolean;
function StartLogin (const AUsuario : String = ''; const APassword : String = ''): Boolean;
procedure VerUsuarios;
procedure VerPerfiles;
@ -174,7 +174,7 @@ uses
uDAInterfaces, uDataTableUtils, uDialogUtils, uFactuGES_App, Dialogs,
uDateUtils, uROTypes, DateUtils, Controls, Windows, uIEditorLogin,
uIEditorUsuarios, uIEditorUsuario, uIEditorPerfilesUsuario,
uIEditorPerfilUsuario, uEditorCambiarPassword;
uIEditorPerfilUsuario, uEditorCambiarPassword, uStringsUtils;
{ TUsuariosController }
@ -856,22 +856,39 @@ begin
FUserControl.ShowUserManager;
end;
function TUsuariosController.StartLogin : Boolean;
function TUsuariosController.StartLogin (const AUsuario : String = '';
const APassword : String = ''): Boolean;
var
AEditor : IEditorLogin;
begin
Result := False;
AEditor := NIL;
CreateEditor('EditorLogin', IEditorLogin, AEditor);
if Assigned(AEditor) then
// Intentamos un login automático si hay datos en los parámetros
if not EsCadenaVacia(AUsuario) and not EsCadenaVacia(APassword) then
begin
ShowHourglassCursor;
try
AEditor.Controller := Self;
Result := (AEditor.ShowModal = mrOk);
Result := ComprobarUsuario(AUsuario, APassword);
finally
AEditor.Release;
AEditor := NIL;
HideHourglassCursor;
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;
procedure TUsuariosController.FiltrarEmpresa(AUsuario: IBizUsuario);

View File

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

View File

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

View File

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

View File

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

View File

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