{{indexmenu_n>1}}
=====LOGIN=====
====Customized Login Screen====
\\
In some cases, we may need to customize the usual login screen. \\
\\
All we have to do is define a collection with the design we want for the login. To this collection we have to put an attribute ** login-coll = "true" ** which is the one that causes that collection to become "Login Screen".\\
\\
=== login.xml sample File ===
\\
000000
\\
.**vbs** code file that is included in the **Empresas** collection.\\
\\
function login()
Dim st_msg,ObjB,st_erraut,CollB,CollC,ObjC
st_msg=""
'Forzar al usuario a introducir nombre de usuario y contraseña
if This("MAP_USUARIO")="" or This("MAP_PWD")="" then
st_msg="Introduzca nombre de usuario y clave"
end if
if st_msg <> "" then
appdata.failwithmessage -8100,st_msg
else
st_erraut=""
Set CollB=appdata.GetCollection("Usuarios")
CollB.filter="LOGIN='"+Cstr(This("MAP_USUARIO")) +"'"
CollB.StartBrowse
Set ObjB=CollB.CurrentItem
if ObjB is nothing then
st_erraut="Nombre de usuario o password incorrecto"
end if
Set ObjB=nothing
CollB.EndBrowse
CollB.Clear
Set CollB=nothing
'Si todo OK, intentamos el logueo
if st_erraut="" then
This.Variables("##LOGIN_USERCOLL##")="Usuarios"
This.Variables("##LOGIN_NEWUSER##")="LOGIN,"+This("MAP_USUARIO")
This.Variables("##LOGIN_NEWPASS##")="PWD,"+This("MAP_PWD")
This.Variables("##LOGIN_NEWNOUSERIN##")=0
appdata.failwithmessage -11888,"##LOGIN_START##"
else
appdata.failwithmessage -8100,st_erraut
end if
end if
end function
==== New way to make LOGIN ====
A new way to login has been defined in XOne applications.\\
\\
Within the ** appData ** object , we find the following methods related to the login.\\
\\
^ METHOD ^ DESCRIPTION ^
^ login(object) | it is to make login in the application, it replaces the old appData.failWithMessage(-11888,##LOGIN_START##”)
\\
The object passed has to be the following structure:\\
\\
{
userName: /*user*/,
password: /*password*/,
entryPoint: /*Collection entryPoint that will be opened when the login is successful.*/,
/*Optional*/
onLoginSuccessful: function() {
/*Do something when login is successful.*/
},
/*Optional*/
onLoginFailed: function() {
/*Do something when login is wrong.*/
}
};
\\
**Sample:**\\
\\
function doLogin() {
var params = {
userName: self.MAP_USER,
password: self.MAP_PASSWORD,
entryPoint: "MenuEntrada2",
/* Opcional */
onLoginSuccessful: function() {
ui.showToast("Login OK!");
},
/* Opcional */
onLoginFailed: function() {
ui.showToast("Login failed!");
}
};
appData.login(params);
}
|
^ logout | It closes session and back to the login screen.
appData.logout();
|
^ exit | It closes the application, it replaces the old appData.failWithMessage(-11888,## EXITAPP##”)
appData.exit();
|