Update logged user password laravel 5

i want to add password update option for logged user therefore i used following code

controller authauthController.php

public function updatePassword()
    {

        $user = Auth::user();
        $rules = array(
            'old_password' => 'required',
            'password' => 'required|alphaNum|between:6,16|confirmed'
        );

        $validator = Validator::make(Input::all(), $rules);

        if ($validator->fails()) {
            return Redirect::route('change-password', $user->id)->withErrors($validator);
        } else {
            if (!Hash::check(Input::get('old_password'), $user->password)) {
                return Redirect::route('change-password', $user->id)->withErrors('Your old password does not match');
            } else {
                $user->password = Input::get('password');
                $user->save();
                return Redirect::route('change-password', $user->id)->with("message", "Password have been changed");
            }
        }
    }

Routes

Route::post('change-password', 'AuthAuthController@updatePassword');
Route::get('change-password', 'AuthAuthController@updatePassword');

im getting following error

FatalErrorException in AuthController.php line 123:
Class 'AppHttpControllersAuthAuth' not found

for this line “$user = Auth::user();”


Source: laravel

Leave a Reply