Description


Core\Auth\User auth()


Using our auth() function will give you access to our core authentication class.

Examples


<?php

route('/foo', function() {

   // Check if a user is logged in
   if (auth()->isLoggedIn()) {
      echo "Hello logged in user!";
   }

   // Check if the user is an admin
   if (auth()->isAdmin()) {
      echo "Hello Admin!";
   }

});


route('/bar', function() {

   // This will redirect the user if they are not logged in
   auth()->membersOnly();

});

Methods


MethodDescriptionUsageReturns
isLoggedIn()

Check if a user is logged in or not.

if (auth()->isLoggedIn()) {
	echo "Hello logged in user!";
}

true if logged in, false if not

membersOnly()

Redirect a user to the login page if they are

not logged in.

route('/bar', function() {

   // This will redirect the user if they are not logged in
   auth()->membersOnly();

});
null
isAdmin()Checks to see if a user is a site Admin
if (auth()->isAdmin()) {
	echo "Hello Admin!";
}
true if logged in, false if not