Bladeren bron

Use role constants for roles

ohartl 9 jaren geleden
bovenliggende
commit
6bd36d6623
3 gewijzigde bestanden met toevoegingen van 4 en 4 verwijderingen
  1. 1 1
      include/php/classes/Auth.php
  2. 1 1
      include/php/template/header.php
  3. 2 2
      index.php

+ 1 - 1
include/php/classes/Auth.php

@@ -125,7 +125,7 @@ class Auth
 
 
 	/**
-	 * Check if current user has a certain role
+	 * Check if current user has a certain role, but User::ROLE_ADMIN will have access to all
 	 *
 	 * @param string $requiredRole
 	 *

+ 1 - 1
include/php/template/header.php

@@ -30,7 +30,7 @@
 					<a href="<?php echo url('private'); ?>">[Personal Dashboard]</a>
 				</div>
 			<?php endif; ?>
-			<?php if(Auth::hasPermission('user')): ?>
+			<?php if(Auth::isLoggedIn()): ?>
 				<div class="header-button">
 					Logged in as <?php echo Auth::getUser()->getEmail(); ?>
 					<a href="<?php echo url('logout'); ?>">[Logout]</a>

+ 2 - 2
index.php

@@ -31,7 +31,7 @@ function load_page($p){
 	
 	if(preg_match("/^\/private(.*)$/", $p) == 1){
 		// Page is user page
-		if(Auth::hasPermission('user')){
+		if(Auth::hasPermission(User::ROLE_USER)){
 			switch($p){
 				case "/private/":
 					return "include/php/pages/private/start.php";
@@ -48,7 +48,7 @@ function load_page($p){
 
 	else if(preg_match("/^\/admin(.*)$/", $p) == 1){
 		// Page is admin page
-		if(Auth::hasPermission('admin')){
+		if(Auth::hasPermission(User::ROLE_ADMIN)){
 			switch($p){
 				case "/admin/":
 					return "include/php/pages/admin/start.php";