Paragonik/LoginController.php

53 lines
1.4 KiB
PHP
Raw Normal View History

2020-01-13 17:49:05 +01:00
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//$this->middleware('guest')->except('logout');
}
public function loginAPI(Request $request){
$this->validate($request, [
'email' => 'required',
'password' => 'required',
]);
if(Auth::guard('api')->attempt([
'email' => $request->email,
'password' => $request->password]))
{
return response()->json(["message " => "Accepted."], 200);
}
else{
return response()->json(["message " => "Record not found."], 202);
}
}
}