64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Webkul\User\Http\Controllers;
|
||
|
|
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Http\Response;
|
||
|
|
use Illuminate\Routing\Controller;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Admin user session controller
|
||
|
|
*
|
||
|
|
* @author Jitendra Singh <jitendra@webkul.com>
|
||
|
|
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||
|
|
*/
|
||
|
|
class SeesionController extends Controller
|
||
|
|
{
|
||
|
|
protected $_config;
|
||
|
|
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
$this->_config = request('_config');
|
||
|
|
|
||
|
|
$this->middleware('guest', ['except' => 'destroy']);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Show the form for creating a new resource.
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function create()
|
||
|
|
{
|
||
|
|
return view($this->_config['view']);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Store a newly created resource in storage.
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function store()
|
||
|
|
{
|
||
|
|
if(! auth()->guard('admin')->attempt(request(['email', 'password']))) {
|
||
|
|
return back()->withErrors([
|
||
|
|
'message' => 'Please check your credentials and try again.'
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
return redirect($this->_config['redirect']);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Remove the specified resource from storage.
|
||
|
|
*
|
||
|
|
* @param int $id
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function destroy($id)
|
||
|
|
{
|
||
|
|
auth()->guard('admin')->logout();
|
||
|
|
|
||
|
|
return redirect($this->_config['redirect']);
|
||
|
|
}
|
||
|
|
}
|