sarga/packages/Webkul/API/Http/Controllers/Customer/AuthController.php

47 lines
1.3 KiB
PHP
Raw Normal View History

2018-11-17 13:56:48 +00:00
<?php
namespace Webkul\API\Http\Controllers\Customer;
use Webkul\API\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
2018-11-21 06:29:18 +00:00
// use Webkul\Customer\Http\Listeners\CustomerEventsHandler;
use Auth;
2018-11-17 13:56:48 +00:00
use Cart;
/**
* Session controller for the APIs of user customer
*
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class AuthController extends Controller
{
/**
2018-11-21 06:29:18 +00:00
* To get the details of user to display on profile
*
2018-11-21 06:29:18 +00:00
* @return response JSON
*/
2018-11-21 06:29:18 +00:00
public function create() {
$data = request()->except('_token');
2018-11-17 13:56:48 +00:00
if(!auth()->guard('customer')->check()) {
if(!auth()->guard('customer')->attempt($data)) {
return response()->json(['unauthenticated', 'invalid creds'], 401);
} else {
return response()->json(['authenticated'], 200);
}
} else {
return response()->json(['already authenticated'], 200);
}
}
public function destroy() {
if(auth()->guard('customer')->logout()) {
return response()->json(['logged out'], 200);
2018-11-21 06:29:18 +00:00
} else {
return response()->json(['already logged out'], 200);
2018-11-21 06:29:18 +00:00
}
2018-11-17 13:56:48 +00:00
}
2018-11-21 06:29:18 +00:00
}