Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index(Request $request){
- $email = $request->email;
- $password = $request->password;
- if (!$email || !$password) {return redirect()->back();}
- if (Auth::attempt(['email' => $email, 'password' => $password])) {
- // Authentication passed...
- $this->loggedUser = Auth::user();
- if($this->loggedUser){
- return response()->json(['isLoggedIn' => true],200);
- }
- }
- return response()->json(['isLoggedIn' => false],200);
- }
- Login (body: Object): Observable<Login[]> {
- let bodyString = JSON.stringify(body); // Stringify payload
- let options = new RequestOptions({ headers: this.headers }); // Create a request option
- return this.http.post('/index', body, options) // ...using post request
- .map(response => {return response} ,console.log('aaa')) // ...and calling .json() on the response to return data
- .catch((error:any) => Observable.throw(error.json().error || 'Server error' )); //...errors if any
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement