Skip to content

Instantly share code, notes, and snippets.

@tournasdim
Last active December 21, 2015 09:19
Show Gist options
  • Save tournasdim/6284487 to your computer and use it in GitHub Desktop.
Save tournasdim/6284487 to your computer and use it in GitHub Desktop.
L4 Authentication signature (list of most used functions)
<?php
Route::post('login', function() {
// data from login form
//
$credentials = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
echo Auth::attempt($credentials) ? 'weldone' : 'Sorry' ;
});
/*
Security section of four.laravel.com
*/
Auth::logout() ; return Redirect::to('') ;
Auth::attempt(array('email' => $email, 'password' => $password)) ; // or pass an array to constructor
if (Auth::attempt(array('email' => $email, 'password' => $password, 'active' => 1)){ // do something }
$user = User::find(1);Auth::login($user); // Manually loggin in a user
if (Auth::validate($credentials)){ } // Just validate don't log-in
if (Auth::once($credentials)) { } // Just log-in for a single request
Auth::loginUsingId(1);//Log the given user ID into the application
Auth::login(UserInterface $user, $remember = false) ; Login a user by inserting an User object
Auth::check() //returns true if a user is currently logged in, and false otherwise
Auth::guest() //is the opposite of Auth::check(). It returns false if a user is logged in, and true otherwise.
Auth::user()->email ; // It uses Eloquent's functionality to query the database and returns an object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment