PHP code example of dayed / auth2

1. Go to this page and download the library: Download dayed/auth2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dayed / auth2 example snippets


  
    return array(
    
    	// example 
    	'admin'	=>	array(
    		'driver' 	=> 'eloquent',
    		'model' 	=> 'Admin',
    		'table' 	=> 'admins',
    		'view' 		=> 'emails.auth.reminder'
    	),		
    
    );

  

  
  Auth2::admin()->attempt($credentials, $remember);
  
  if(Auth2::admin()->check())
  {
    // code
  }
  
  Auth2::admin()->get(); //it's same with Auth::user() , for get credentials
  
  Auth2::admin()->logout();
  
  

  
    /**
	 * Handle a POST request to remind a user of their password.
	 *
	 * @return Response
	 */
	public function postRemind()
	{
		$response = Password2::admin()->remind(Input::only('email'), function($message)
		{
		    $message->subject('Password Reminder');
		});

		switch ($response)
		{
			case 'reminders.user':
				return Redirect::back()->with('error', Lang::get($response));

			case 'reminders.sent':
				return Redirect::back()->with('status', Lang::get($response));
		}
	}
  

  	
	/**
	 * Handle a POST request to reset a user's password.
	 *
	 * @return Response
	 */
	public function postReset()
	{
    		$credentials = Input::only(
			'email', 'password', 'password_confirmation', 'token'
		);

		$response = Password2::admin()->reset($credentials, function($user, $password)
		{
			$user->password = Hash::make($password);

			$user->save();
		});

		switch ($response)
		{
			case 'reminders.password':
			case 'reminders.token':
			case 'reminders.user':
				return Redirect::back()->with('error', Lang::get($response));

			case 'reminders.reset':
				return Redirect::to('admin');
		}
	}
  

  php artisan config:publish pingpong/auth2