tournasdim
8/20/2013 - 5:24 PM

L4 Authentication signature (list of most used functions)

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