{"action":"closed","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/14516","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/14516/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/14516/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/14516/events","html_url":"https://github.com/laravel/framework/issues/14516","id":168045144,"number":14516,"title":"Still TokenMisMatch exception ","user":{"login":"forexknight","id":19877482,"avatar_url":"https://avatars.githubusercontent.com/u/19877482?v=3","gravatar_id":"","url":"https://api.github.com/users/forexknight","html_url":"https://github.com/forexknight","followers_url":"https://api.github.com/users/forexknight/followers","following_url":"https://api.github.com/users/forexknight/following{/other_user}","gists_url":"https://api.github.com/users/forexknight/gists{/gist_id}","starred_url":"https://api.github.com/users/forexknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forexknight/subscriptions","organizations_url":"https://api.github.com/users/forexknight/orgs","repos_url":"https://api.github.com/users/forexknight/repos","events_url":"https://api.github.com/users/forexknight/events{/privacy}","received_events_url":"https://api.github.com/users/forexknight/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-28T08:54:53Z","updated_at":"2016-07-29T06:55:03Z","closed_at":"2016-07-29T06:55:03Z","body":"Hello,\r\nI'm facing very strange problem in my previous project I hadn't problems like these. \r\nThe problem is that when sometimes I log in (and on other pages where I use post method) I get TokenMisMatch exception on line 67. The same thing happens if I use post ajax requests (get are working properly). I asked this question on stackoverflow but nobody helped me, they don't have any ideas how to solve it. \r\n\r\nLaravel version: **5.2.41**\r\n\r\nMy User model:\r\n```\r\nclass User extends Authenticatable\r\n{\r\n  public $timestamps = false;\r\n  protected $primaryKey = 'idx_osoby';\r\n  protected $table = 'public.users';\r\n\r\n  /**\r\n   * The attributes that should be hidden for arrays.\r\n   *\r\n   * @var array\r\n   */\r\n}\r\n```\r\n\r\nMy login function:\r\n\r\n```\r\npublic function login(Request $request) {\r\n      $this->validate($request,[\r\n        'login' => 'required',\r\n        'hasło' => 'required'\r\n      ]);\r\n      $user = User::where('login','=',$request['login'])->first();\r\n      if (isset($user))\r\n      {\r\n\r\n        //jeśli użytkownik ma stare hasło zaszyfrowane w md5 - zmieniamy je na laravelowe oraz logujemy go.\r\n        if($user->pass_online == md5($request['hasło'])) {\r\n          DB::table('public.users')\r\n              ->where('login',$request['login'])\r\n              ->where('idx_osoby',$user->idx_osoby)\r\n              ->update([\r\n                'pass_online' => bcrypt($request['hasło'])\r\n              ]);\r\n          Auth::login($user, true);\r\n          return redirect()->route('GetDashboard')->with(['logged_in' => 'logged_in']);\r\n        }\r\n        //logowanie na hasło laravela.\r\n        elseif (Hash::check($request['hasło'],$user->pass_online))\r\n        {\r\n          Auth::login($user, true);\r\n          return redirect()->route('GetDashboard')->with(['logged_in' => 'logged_in']);\r\n        }\r\n        //błędny login lub hasło.\r\n        else {\r\n          return redirect()->back()->with([\r\n            'message' => 'Błędny login lub hasło.'\r\n          ]);\r\n        }\r\n      }\r\n      // nie ma takiego użytkownika.\r\n      else {\r\n        return redirect()->back()->with([\r\n          'message' => 'Błędny login lub hasło.'\r\n        ]);\r\n      }\r\n    }\r\n```\r\nLogin form:\r\n```\r\n<form method=\"POST\" action=\"{{Route('Userlogin')}}\">\r\n                   <div class=\"form-group\">\r\n                      <label for=\"Login\">Login:</label>\r\n                      <input type=\"text\" class=\"form-control\" name=\"login\" id=\"Login\">\r\n                    </div>\r\n                    <div class=\"form-group\">\r\n                      <label for=\"Hasło\">Hasło:</label>\r\n                      <input type=\"password\" class=\"form-control\" name=\"hasło\" id=\"Haslo\">\r\n                    </div>\r\n                    <button class=\"btn btn-special\">Zaloguj się</button>\r\n                   <input type=\"hidden\" name=\"_token\" value=\"{{Session::token()}}\">\r\n                   <br>\r\n                   <br>\r\n                   @include('includes.errors')\r\n                 </form>\r\n```\r\nJquery ajax: \r\n```\r\n$('#testowy').on('click',function() {\r\n    var x = 'Hej';\r\n    $.ajax({\r\n      method:\"post\",\r\n      url:urlPost,\r\n      data:{\r\n        _token:token,\r\n        x:x\r\n      }\r\n      }).done(function(msg) {\r\n        console.log(msg)\r\n      });\r\n  });\r\n```\r\n\r\nExample ajax request (first request is ok, but then I get errors): \r\n![image](https://cloud.githubusercontent.com/assets/19877482/17206631/fc55075a-54b0-11e6-95e2-3862d13f494a.png)\r\n\r\n\r\nI think that it can be something wrong netiher with database or with login controller, because I have custom users table.\r\nAny help will be really appreciated, I'm facing this problem for 2 days and I really don't know what's wrong :("}}
{"actor":{"display_login":"forexknight"}}