This example was created using the Scritpcase native security module
Access an app_login application, make the security module, in the application settings access the onValidate event.
In this event it is possible to obtain the login used by the client [usr_login].
- if(sc_logged_is_blocked()) { sc_error_exit(); }
- $slogin = sc_sql_injection({login});
- $spswd = sc_sql_injection(hash("md5",{pswd}));
- $sql = "SELECT
- priv_admin,
- active,
- name,
- email
- FROM sec_users
- WHERE login = $slogin
- AND pswd = ".$spswd."";
- sc_lookup(rs, $sql);
- if(count({rs}) == 0)
- {
- sc_log_add('login Fail', {lang_login_fail} . {login});
- sc_logged_in_fail({login});
- sc_error_message({lang_error_login});
- }
- else if({rs[0][1]} == 'Y')
- {
- $usr_login = {login};
- $usr_priv_admin = ({rs[0][0]} == 'Y') ? TRUE : FALSE;
- $usr_name = {rs[0][2]};
- $usr_email = {rs[0][3]};
- sc_set_global($usr_login);
- sc_set_global($usr_priv_admin);
- sc_set_global($usr_name);
- sc_set_global($usr_email);
- }
- else
- {
- sc_error_message({lang_error_not_active});
- sc_error_exit();
- }
2. Then access the menu application. Access the onAplicationInit event and use the code below
- $sql = "SELECT name FROM sec_users WHERE login = '".[]."'";
- sc_lookup(ds,$sql);
- sc_reset_global([var_glob1]);
- [nome] = {ds[0][0]};
3. Then go to Layout> Header & Footer and then we will assign the value of the variable [name] to one of the header variables.
4. Then, when accessing the login, the user name will be displayed in the menu header.