@prashant-webkul * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class AuthController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ protected $_config; public function __construct() { $this->middleware('customer')->except(['show','create']); $this->_config = request('_config'); $subscriber = new CustomerEventsHandler; Event::subscribe($subscriber); } public function create(Request $request) { $request->validate([ 'email' => 'required|email', 'password' => 'required' ]); if (!auth()->guard('customer')->attempt(request(['email', 'password']))) { return response()->json([false], 200); } if(auth()->guard('customer')->check()) { $customer = auth()->guard('customer')->user(); $token = $customer->createToken('customer-token')->accessToken; return response()->json([$token], 200); } else { return response()->json([false], 200); } } public function destroy($id) { auth()->guard('customer')->logout(); Event::fire('customer.after.logout', $id); return redirect()->route($this->_config['redirect']); } }