How to get current logged in user in validator (using route vailidator)

Hi guys, i’m new with adonisjs.
Currently, i want to get current logged in user in my validator (because i want to change rules based on users is logged in or not). Can you guys tell me how to do this? Thanks

1 Like


You can take a look into this

You can perhaps access this.ctx.auth in validator

1 Like

@McSneaky Thanks for your reply.

I’ve already read this. But to get current logged in user, it should be used with await. But rules is getter and can not be async function.

As McSneaky said:

get rules() {
    const user = this.ctx.auth.user

    return {} 
1 Like

@dragoneyes Did you ever sort this.


return a promise and await can not be used inside get rules()


returns null