{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/13446","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/13446/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/13446/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/13446/events","html_url":"https://github.com/laravel/framework/issues/13446","id":153315019,"number":13446,"title":"Authentication view is not working but registration view is working fine","user":{"login":"aliqasim94","id":19213052,"avatar_url":"https://avatars.githubusercontent.com/u/19213052?v=3","gravatar_id":"","url":"https://api.github.com/users/aliqasim94","html_url":"https://github.com/aliqasim94","followers_url":"https://api.github.com/users/aliqasim94/followers","following_url":"https://api.github.com/users/aliqasim94/following{/other_user}","gists_url":"https://api.github.com/users/aliqasim94/gists{/gist_id}","starred_url":"https://api.github.com/users/aliqasim94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aliqasim94/subscriptions","organizations_url":"https://api.github.com/users/aliqasim94/orgs","repos_url":"https://api.github.com/users/aliqasim94/repos","events_url":"https://api.github.com/users/aliqasim94/events{/privacy}","received_events_url":"https://api.github.com/users/aliqasim94/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-05T20:12:33Z","updated_at":"2016-05-05T20:52:17Z","closed_at":null,"body":"I am new to laravel. i have seen some related posts but i could not find right answer. I made an auth using php artisan make:auth, i have a directory publicPages. I have changed the auth.login view to my custom publicPages.login and publicPages.register. Registration process works fine, inserts the data into users table. but it does not login the user. When i go to login view and enter credentials. It neither give any error nor log the user in. just redirects it to back.\r\n\r\nHere are routes:\r\n\r\n       Route::auth();\r\n\r\n       Route::controllers([\r\n\r\n       'auth' => 'Auth\\AuthController',\r\n\r\n    '   password' => 'Auth\\PasswordController'\r\n\r\n       ]);\r\n\r\n    Route::group(array('namespace' => 'UserControllers'), function()\r\n\r\n    {\r\n\r\n    Route::group(['middleware' => ['web']], function() {\r\n\r\n        Route::group(['middleware' => 'auth'], function () {\r\n\r\n        Route::get('community', 'UserController@showCommunity');\r\n\r\n        Route::post('communities', 'UserController@addCommunity');\r\n\r\n        Route::get('edit/{id}', ['as' => 'edit', 'uses' => 'UserController@editCommunity']);\r\n\r\n        Route::get('delete/{id}', 'UserController@deleteCommunity');\r\n\r\n        Route::post('update/{id}', ['as' => 'update', 'uses' => 'UserController@updateCommunity']);\r\n\r\n        Route::get('create', 'IdeaController@displayPost');\r\n\r\n        Route::post('idea', 'IdeaController@storePost');\r\n\r\n        Route::get('users', 'UserController@showUserListing');\r\n\r\n        Route::get('deleteUser/{id}', 'UserController@deleteUser');\r\n\r\n        Route::get('delete/idea/{id}', 'IdeaController@deleteIdea');\r\n\r\n        Route::get('approve/{id}', 'IdeaController@approveIdea');\r\n\r\n       });\r\n       });\r\n\r\n\r\nController:\r\n\r\n   class UserController extends Controller {\r\n\r\n    //constructor\r\n    public function __construct() {\r\n        $this->middleware('auth');\r\n    }\r\nI know when i would use $this->middleware('auth'); it would redirect to login page for every UserController function. which is working fine.\r\n\r\nView:\r\n\r\n    <form id=\"login-form\" class=\"clearfix\" action=\"{{url('/login')}}\" method=\"post\">\r\n\r\n    <input type=\"hidden\" name=\"_token\" value=\"{{ csrf_token() }}\">\r\n\r\n    <p class=\"rs pb30\">Please Provide your Credentials to Verify Your Identity</p>\r\n\r\n    <div class=\"form form-post-comment\">\r\n\r\n    <div class=\"fa-align-center\">\r\n\r\n    <label for=\"login_email\">\r\n\r\n    <input id=\"login_email\" type=\"email\" name=\"email\" class=\"txt fill-width txt-name{{ $errors->has('email') ? ' has-error'            : '' }}\" placeholder=\"Enter Your Email\" required=\"required\"/>\r\n\r\n    </label>\r\n\r\n       @if ($errors->has('email'))\r\n\r\n       <span class=\"help-block\">\r\n\r\n       <strong>{{ $errors->first('email') }}</strong>\r\n\r\n       </span>\r\n\r\n      @endif\r\n\r\n      <br><br>\r\n\r\n      <label for=\"password\">\r\n\r\n      <input id=\"password\" type=\"password\" name=\"login_password\" class=\"txt fill-width txt-email\" placeholder=\"Enter Your Password\" required=\"required\"/>\r\n\r\n      </label> <br><br>\r\n\r\n      <label for=\"links\">\r\n\r\n      <a href=\"/changepassword\" class=\"txt-emphasis\">Forgotten Password?</a>\r\n\r\n      <p>Don't have an account? <a href=\"/register\" class=\"txt-emphasis\">Register Here</a> </p>\r\n\r\n      </label>\r\n\r\n      </div>\r\n\r\n      <div class=\"clear\"></div>\r\n\r\n      <p >\r\n\r\n      <span id=\"response\"></span>\r\n\r\n      {{--<input type=\"submit\" class=\"btn btn-submit-comment\" value=\"Login\">--}}\r\n\r\n      <button class=\"btn btn-submit-comment\" form=\"login-form\">Login</button>\r\n\r\n      </p>\r\n\r\n      </div>\r\n\r\nHere is AuthenticatesUsers file:\r\n\r\n     <?php\r\n\r\n     namespace Illuminate\\Foundation\\Auth;\r\n\r\n     use Illuminate\\Http\\Request;\r\n     use Illuminate\\Support\\Facades\\Auth;\r\n     use Illuminate\\Support\\Facades\\Lang;\r\n     //use App\\Http\\Requests\\UserRequest;\r\n\r\n     trait AuthenticatesUsers\r\n     {\r\n         use RedirectsUsers;\r\n\r\n    /**\r\n     * Show the application login form.\r\n     *\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    public function getLogin()\r\n    {\r\n        return $this->showLoginForm();\r\n    }\r\n\r\n    /**\r\n     * Show the application login form.\r\n     *\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    public function showLoginForm()\r\n    {\r\n        $view = property_exists($this, 'loginView')\r\n                    ? $this->loginView : 'auth.authenticate';\r\n\r\n        if (view()->exists($view)) {\r\n            return view($view);\r\n        }\r\n\r\n        return view('publicPages.login');\r\n    }\r\n\r\n    /**\r\n     * Handle a login request to the application.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request  $request\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    public function postLogin(Request $request)\r\n    {\r\n        return $this->login($request);\r\n    }\r\n\r\n    /**\r\n     * Handle a login request to the application.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request  $request\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    public function login(Request $request)\r\n    {\r\n        $this->validateLogin($request);\r\n\r\n        // If the class is using the ThrottlesLogins trait, we can automatically throttle\r\n        // the login attempts for this application. We'll key this by the username and\r\n        // the IP address of the client making these requests into this application.\r\n        $throttles = $this->isUsingThrottlesLoginsTrait();\r\n\r\n        if ($throttles && $lockedOut = $this->hasTooManyLoginAttempts($request)) {\r\n            $this->fireLockoutEvent($request);\r\n\r\n            return $this->sendLockoutResponse($request);\r\n        }\r\n\r\n        $credentials = $this->getCredentials($request);\r\n\r\n        if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {\r\n            return $this->handleUserWasAuthenticated($request, $throttles);\r\n        }\r\n\r\n        // If the login attempt was unsuccessful we will increment the number of attempts\r\n        // to login and redirect the user back to the login form. Of course, when this\r\n        // user surpasses their maximum number of attempts they will get locked out.\r\n        if ($throttles && ! $lockedOut) {\r\n            $this->incrementLoginAttempts($request);\r\n        }\r\n\r\n        return $this->sendFailedLoginResponse($request);\r\n    }\r\n\r\n    /**\r\n     * Validate the user login request.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request  $request\r\n     * @return void\r\n     */\r\n    protected function validateLogin(Request $request)\r\n    {\r\n        $this->validate($request, [\r\n            $this->loginUsername() => 'required', 'password' => 'required',\r\n        ]);\r\n    }\r\n\r\n    /**\r\n     * Send the response after the user was authenticated.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request  $request\r\n     * @param  bool  $throttles\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    protected function handleUserWasAuthenticated(Request $request, $throttles)\r\n    {\r\n        if ($throttles) {\r\n            $this->clearLoginAttempts($request);\r\n        }\r\n\r\n        if (method_exists($this, 'authenticated')) {\r\n            return $this->authenticated($request, Auth::guard($this->getGuard())->user());\r\n        }\r\n\r\n        return redirect()->intended($this->redirectPath());\r\n    }\r\n\r\n    /**\r\n     * Get the failed login response instance.\r\n     *\r\n     * @param \\Illuminate\\Http\\Request  $request\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    protected function sendFailedLoginResponse(Request $request)\r\n    {\r\n        return redirect()->back()\r\n            ->withInput($request->only($this->loginUsername(), 'remember'))\r\n            ->withErrors([\r\n                $this->loginUsername() => $this->getFailedLoginMessage(),\r\n            ]);\r\n    }\r\n\r\n    /**\r\n     * Get the failed login message.\r\n     *\r\n     * @return string\r\n     */\r\n    protected function getFailedLoginMessage()\r\n    {\r\n        return Lang::has('auth.failed')\r\n                ? Lang::get('auth.failed')\r\n                : 'These credentials do not match our records.';\r\n    }\r\n\r\n    /**\r\n     * Get the needed authorization credentials from the request.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request  $request\r\n     * @return array\r\n     */\r\n    protected function getCredentials(Request $request)\r\n    {\r\n        return $request->only($this->loginUsername(), 'password');\r\n    }\r\n\r\n    /**\r\n     * Log the user out of the application.\r\n     *\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    public function getLogout()\r\n    {\r\n        return $this->logout();\r\n    }\r\n\r\n    /**\r\n     * Log the user out of the application.\r\n     *\r\n     * @return \\Illuminate\\Http\\Response\r\n     */\r\n    public function logout()\r\n    {\r\n        Auth::guard($this->getGuard())->logout();\r\n\r\n        return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');\r\n    }\r\n\r\n    /**\r\n     * Get the guest middleware for the application.\r\n     */\r\n    public function guestMiddleware()\r\n    {\r\n        $guard = $this->getGuard();\r\n\r\n        return $guard ? 'guest:'.$guard : 'guest';\r\n    }\r\n\r\n    /**\r\n     * Get the login username to be used by the controller.\r\n     *\r\n     * @return string\r\n     */\r\n    public function loginUsername()\r\n    {\r\n        return property_exists($this, 'username') ? $this->username : 'email';\r\n    }\r\n\r\n    /**\r\n     * Determine if the class is using the ThrottlesLogins trait.\r\n     *\r\n     * @return bool\r\n     */\r\n    protected function isUsingThrottlesLoginsTrait()\r\n    {\r\n        return in_array(\r\n            ThrottlesLogins::class, class_uses_recursive(static::class)\r\n        );\r\n    }\r\n\r\n    /**\r\n     * Get the guard to be used during authentication.\r\n     *\r\n     * @return string|null\r\n     */\r\n    protected function getGuard()\r\n    {\r\n        return property_exists($this, 'guard') ? $this->guard : null;\r\n    }\r\n}\r\nis There anything i need to change in postLoginForm() ? Thanks\r\n\r\n\r\nupdate 2: \r\n\r\nI have changed postLoginForm() function's code to\r\n\r\n      if (Auth::attempt(['email' => $email, 'password' => $password])) \r\n\r\n       {\r\n\r\n            // Authentication passed...\r\n\r\n            return redirect()->intended('dashboard');\r\n\r\n           } else {\r\n\r\n           echo 'not logged in';\r\n\r\n            }\r\nnow finally it prints not logged in but even i use true credentials it says not logged in. But even if i provide true credentials it prints not logged in"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/217275995","html_url":"https://github.com/laravel/framework/issues/13446#issuecomment-217275995","issue_url":"https://api.github.com/repos/laravel/framework/issues/13446","id":217275995,"user":{"login":"Mathius17","id":6528566,"avatar_url":"https://avatars.githubusercontent.com/u/6528566?v=3","gravatar_id":"","url":"https://api.github.com/users/Mathius17","html_url":"https://github.com/Mathius17","followers_url":"https://api.github.com/users/Mathius17/followers","following_url":"https://api.github.com/users/Mathius17/following{/other_user}","gists_url":"https://api.github.com/users/Mathius17/gists{/gist_id}","starred_url":"https://api.github.com/users/Mathius17/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mathius17/subscriptions","organizations_url":"https://api.github.com/users/Mathius17/orgs","repos_url":"https://api.github.com/users/Mathius17/repos","events_url":"https://api.github.com/users/Mathius17/events{/privacy}","received_events_url":"https://api.github.com/users/Mathius17/received_events","type":"User","site_admin":false},"created_at":"2016-05-05T20:52:17Z","updated_at":"2016-05-05T20:52:17Z","body":"@aliqasim94 It's nice that you're learning Laravel, but I don't think this is the right place to post this type of questions. You should try the Laracasts Forum, laravel.io, stackoverflow.com, etc."}}