Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public function index(Request $request){
  2. $email = $request->email;
  3. $password = $request->password;
  4. if (!$email || !$password) {return redirect()->back();}
  5. if (Auth::attempt(['email' => $email, 'password' => $password])) {
  6. // Authentication passed...
  7. $this->loggedUser = Auth::user();
  8. if($this->loggedUser){
  9.  
  10. return response()->json(['isLoggedIn' => true],200);
  11. }
  12.  
  13. }
  14. return response()->json(['isLoggedIn' => false],200);
  15.  
  16. }
  17.  
  18. Login (body: Object): Observable<Login[]> {
  19. let bodyString = JSON.stringify(body); // Stringify payload
  20.  
  21. let options = new RequestOptions({ headers: this.headers }); // Create a request option
  22.  
  23. return this.http.post('/index', body, options) // ...using post request
  24. .map(response => {return response} ,console.log('aaa')) // ...and calling .json() on the response to return data
  25. .catch((error:any) => Observable.throw(error.json().error || 'Server error' )); //...errors if any
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement