Redirect user with an object

I’m doing a simple login system with session where the user logs in the “login” page ajax sends a post to “/ validLogin” and if the user is valid redirects to “panel” with some data but I’m not able to none

Already tried:
const data = await auth.user.modulos().fetch()
response.redirect(’/panel’, { Modulos: data })

Already tried:
const data = await auth.user.modulos().fetch()
response.route(’/panel’, { Modulos: data })

@each(u in Modulos)
@endeach

Already tried:
@each(u in auth.user.modulos().fetch())
@endeach

Already tried:
@each(u in auth.user.modulos())
@endeach

it works but keeps the url of the request and I want to redirect the user:
view.render(‘panel.index’, DATA)

SESSION:
const data = await auth.user.modulos().fetch()
session.put(‘Modulos’, data.toJSON())
response.route(‘panel’)

@each(u in Modulos)
empty return, since I hitched with session.get and had value saved correctly
@endeach

All I need to do is fetch an object from the database either by the controller and then sending it to the route or direct to the edge I am not getting it at all and I don’t have much information on the network.

I want to loop with an object.

Note: using VIEW it keeps the url “valid Login” WHAT I DON’T WANT! I want to redirect the user.

can anybody help me? I’m already 3 days reading the documentation and nothing works

1 Like

Hi @JonhnyDev

Seems like you are looking for auth.check() https://adonisjs.com/docs/4.1/authentication#_check
and response.redirect() https://adonisjs.com/docs/4.1/response#_redirects
If you look at redirect it accepts 3 parameters, URL, boolean to send parameters and redirect code.
Since it’s not doing internal redirect there is no way to send custom data with it (it actually redirects client to new URL)

2 Likes