forked from science-ation/science-ation
Make user_auth_required aceept and array and return the auth user type.
If the user is required to login before visiting a page, remember the page, and take them to it once they login.
This commit is contained in:
parent
ff01502192
commit
54fe3bf509
21
user.inc.php
21
user.inc.php
@ -797,11 +797,22 @@ function user_auth_required($type, $access='')
|
||||
global $config;
|
||||
if(!isset($_SESSION['users_type'])) {
|
||||
message_push(error(i18n("You must login to view that page")));
|
||||
$_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
|
||||
header("location: {$config['SFIABDIRECTORY']}/user_login.php?type=$type");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($_SESSION['users_type'] != $type) {
|
||||
if(!is_array($type)) $type = array($type);
|
||||
|
||||
$auth_type = false;
|
||||
foreach($type as $t) {
|
||||
if($_SESSION['users_type'] == $t) {
|
||||
$auth_type = $t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($auth_type == false) {
|
||||
message_push(error(i18n("You must login to view that page")));
|
||||
header("location: {$config['SFIABDIRECTORY']}/user_login.php?type=$type");
|
||||
exit;
|
||||
@ -812,19 +823,15 @@ function user_auth_required($type, $access='')
|
||||
exit;
|
||||
}
|
||||
|
||||
if($access != '') {
|
||||
if($type != 'committee') {
|
||||
echo "CRITICAL ERROR, cannot check access in user_auth_required without specifying type=committee";
|
||||
exit;
|
||||
}
|
||||
|
||||
if($auth_type == 'committee' && $access != '') {
|
||||
if(committee_auth_has_access($access) == false) {
|
||||
message_push(error(i18n('You do not have permission to view that page')));
|
||||
header("Location: {$config['SFIABDIRECTORY']}/committee_main.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return $auth_type;
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,7 +233,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Now finally, take them to whatever main page they logged in for */
|
||||
/* Is there a saved requesT_uri from a failed login attempt?, if so
|
||||
* take them there */
|
||||
if(array_key_exists('request_uri', $_SESSION)) {
|
||||
header("location: {$_SESSION['request_uri']}");
|
||||
unset($_SESSION['request_uri']);
|
||||
exit;
|
||||
}
|
||||
header("location: {$type}_main.php");
|
||||
exit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user