PARAG-42 User Login API
This commit is contained in:
parent
c7e85999cd
commit
3f64e933be
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
class LoginController extends Controller
|
class LoginController extends Controller
|
||||||
{
|
{
|
||||||
@ -36,4 +39,21 @@ class LoginController extends Controller
|
|||||||
{
|
{
|
||||||
$this->middleware('guest')->except('logout');
|
$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."], 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ class User extends Authenticatable
|
|||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function receipts()
|
public function receipts()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Receipt');
|
return $this->hasMany('App\Models\Receipt');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user