dimanche 24 janvier 2016

Laravel update password errors

Hi i'm trying to update user password using ajax but i keep getting 500 error.What i've done wrong Here is my controller

public function newPass(Request $request)
    {
        User::where('id','=', Auth::user()->id)->update(['password' => Hash::make($request->password)]);
        return response()->json(array('mess'=>'Update success'));
    }

Here is ajax

$(document).ready(function() {
    $('#btnNewPass').click(function(event) {
        event.preventDefault();
        var pass=$("#password").val();
        $.ajax({
            url: '/updatePass',
            type: 'POST',
            data: {pass: pass},
        })
        .success(function(data) {
         alert(data.mess);
     })
        .error(function() {
            alert("Error");
        });



    });
});

The routes

Route::post('/updatePass','Auth\PasswordController@newPass');



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1nhnwrQ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire