diff --git a/ServiceLoginController.php b/ServiceLoginController.php new file mode 100644 index 0000000..55febac --- /dev/null +++ b/ServiceLoginController.php @@ -0,0 +1,52 @@ +middleware('guest:store'); + } + + public function showLoginForm(){ + return view('auth.service-login'); + } + + public function login(Request $request){ + $this->validate($request, [ + 'email' => 'required', + 'password' => 'required', + ]); + + if(Auth::guard('service')->attempt([ + 'email' => $request->email, + 'password' => $request->password], $request->remember)) + { + return redirect()->intended(route('service.dashboard')); + } + + return redirect()->back(); + } + + public function loginAPI(Request $request){ + $this->validate($request, [ + 'email' => 'required', + 'password' => 'required', + ]); + + if(Auth::guard('service')->attempt([ + 'email' => $request->email, + 'password' => $request->password])) + { + return response()->json(["message " => "Accepted."], 200); + } + else{ + return response()->json(["message " => "Record not found."], 404); + } + } +}