login: replace page editability var by admin status
[minimedit.git] / auth.inc.php
index 6a5d1d2d83458fc1f84f56dd96093c1cb36c0c5b..ecd29b5cc36ca971c9183f9a11ddd31d180d9f24 100755 (executable)
@@ -1,8 +1,7 @@
 <?php
-global $User, $editable;
-$User = FALSE;
+global $User, $Admin;
 
-function Auth() {
+call_user_func(function () {
        if (isset($_SERVER['PHP_AUTH_USER'])) {
                $authinfo = [ $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'] ];
        }
@@ -29,10 +28,8 @@ function Auth() {
        $salt = substr($usertest, 0, 2);
        if (crypt($authpass, $salt) != $usertest) return;
 
-       $GLOBALS['User'] = $authname;
-}
-
-Auth();
-
-$editable = !empty($User) && $User != 'lid';
+       global $User, $Admin;
+       $User = $authname;
+       $Admin = !empty($User) && $User != 'lid' ? $User : FALSE;
+});