mardi 4 octobre 2016

Laravel timeout on auth login

Laravel 5.3 - My goal is to send login form via ajax to login controller (AuthenticatesUsers trait), and to get a response (json would be ok), so i could set timeout before redirect to "dashboard" section (authenticated). I need that timeout for some frontend stuff. So could it be done? If it could, hint would suffice. Thanks in advance.

Javascript example:

$("#login-form").submit(function (e) {

var url = "/login"; // the script where you handle the form input.

$.ajax({
    type: "POST",
    cache : false,
    url: url,
    data: $("#login-form").serialize(), // serializes the form's elements.
    success: function () 
    {       //Do the timeout part, then redirect
            topbar.addClass('success');
            form.addClass('goAway');
            article.addClass('active');
            tries = 0;

    },
    error: function () {
        location.reload(); 
        input.addClass('disabled');
        topbar.addClass('error');
    }

});});

Login form is sent via post, and i would like to do a redirect by myself, not via controller, and my main concern is the csrf token on javascript redirect would change.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire