Advertisement
Guest User

Untitled

a guest
Mar 5th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. function authenticate() {
  2. var form = $('#form-login');
  3. form.submit(function(evt) {
  4. evt.preventDefault();
  5. console.log('submitting!');
  6. console.log(form.serialize());
  7. $.ajax({
  8. type: 'POST',
  9. url: 'http://website.dev/loginz',
  10. data: form.serialize(),
  11. dataType: 'json',
  12. success: function(data) { log_error(data.error); }
  13. });
  14. });
  15. }
  16.  
  17. Route::post('loginz', 'UserLoginController@authenticate');
  18.  
  19. GET http://website.dev/loginz/ 405 (Method Not Allowed)
  20.  
  21. /* POST */
  22. function authenticate(Request $request) {
  23. $username = $request->input('username');
  24. $password = $request->input('password');
  25. if(Auth::attempt(['username' => $username, 'password' => $password])) {
  26. redirect()->route('home'); /* should redirect to player */
  27. }
  28. return response()->json(['error' => trans('errors.user_password_combination').' => '.$username.' & '.$password]);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement