11 New User Notifications
Select a tab above to activate This blank page message helps protect your privacy, or you can show the first message here automatically through settings page
- Melissa Ayre INBOX Re: New security codes Hello again and thanks for being part... 56 seconds ago
- Adison Lee Msed quia non numquam eius 2 minutes ago
- Oliver Kopyuv Msed quia non numquam eius 3 days ago
- Dr. John Cook PhD Msed quia non numquam eius 2 weeks ago
- Sarah McBrook Msed quia non numquam eius 3 weeks ago
- Anothony Bezyeth Msed quia non numquam eius one month ago
- Lisa Hatchensen Msed quia non numquam eius one year ago
-
Administrator UPDATE System updated to version 4.0.3 (patch notes) 5 mins ago
-
Adison Lee replied to your video Cancer Drug Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day... 10 minutes ago
|
[your date here]
|
||||||
|---|---|---|---|---|---|---|
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
| 30 | 1 | 2 | 3 | 4 | 5 | 6 |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | 1 | 2 | 3 |
2:30PM - Doctor's appointment
3:30PM - Report overview
4:30PM - Meeting with Donnah V.
5:30PM - Late Lunch
6:30PM - Report Compression
Warning: Undefined variable $_user in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [0] in function {closure:/var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/lib/debug.php:6} in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [1] in function include_once in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/php_auth_docs.php on line 29
Warning: Attempt to read property "firstname" on null in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [0] in function {closure:/var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/lib/debug.php:6} in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [1] in function include_once in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/php_auth_docs.php on line 29
Warning: Undefined variable $_user in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [0] in function {closure:/var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/lib/debug.php:6} in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [1] in function include_once in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/php_auth_docs.php on line 29
Warning: Attempt to read property "lastname" on null in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [0] in function {closure:/var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/lib/debug.php:6} in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 601 [1] in function include_once in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/php_auth_docs.php on line 29
Warning: Undefined variable $_user in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 602 [0] in function {closure:/var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/lib/debug.php:6} in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 602 [1] in function include_once in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/php_auth_docs.php on line 29
Warning: Attempt to read property "email" on null in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 602 [0] in function {closure:/var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/lib/debug.php:6} in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/includes/header.php on line 602 [1] in function include_once in /var/www/vhosts/plesk.groupe-dmx.fr/dev.groupe-dmx.fr/public/php_auth_docs.php on line 29
- SmartAdmin
- Authentication
- Documentation
Documentation SmartAdmin PHP built-in Authentication routine
Documentation
Authentication
SmartAdmin for PHP comes with a built-in Authentication routine that you can use out of the box. The workflow follows standard security guidelines for authenticating secured pages.
To play around with this feature, head over to the Login page.
Login
There are two ways you can authenticate the user, it's via password or access_token.
With password
// username and password usually from $_POST
$auth = ['username' => $username, 'password' => $password];
$authenticated = \App\App::web_auth($auth);
if ($authenticated) {
// redirect to the secured page
redirect(APP_URL.'/dashboard.php');
} else {
throw Exception('Invalid username or password');
}
If web_auth is successful, you most probably want to redirect the user to a secured page. From there, you can verify the user if already authenticated.
With Access Token
If you want to authenticate the user by access_token, used in the REST API for example, you need to use the \App\App::token_auth method instead.
$user = \App\App::token_auth([
'username' => USERNAME,
'access_token' => ACCESS_TOKEN
]);
Secured pages
When someone opens a secure page, you'll have to check if the user is authenticated. Use can do this by requiring init.auth.php in the page. This will initiate $_SESSION and fill in the $_user global variable -- the current logged-in user.
Note that this requires init.db.php as well, see Database Installation guide.
require_once 'init.php';
// require the db and auth
require_once 'init.db.php';
require_once 'init.auth.php';
// authenticate the page
$app->authenticate_page();
The authenticate_page method will check if the user is authenticated. If the page is opened via a browser, it will redirect automatically to the login page if not authenticated. If the request is via ajax, it will set the HTTP Status to 403 Forbidden.