Strugling with Persona verification token in a Adonisjs+Vue Router

I’m implementing Persona in an Adonisjs (API) + Vuetify+Vue Router SPA and I’m having problems with the token data.

When the user is created I send an email with a link to a page where I take the token and send it to the LoginController where I check it.

Event Listener User.js:

User.registered = async (data) => {

    const emailToken = querystring.encode({

    const tokenUrl = `//localhost:8080/check_email?${emailToken}` 

    const payload = {

    await Mail.send('emails.welcome', payload, (message) => {
          .subject('Bienvenido a Red Empresarial !')


With this I send an email with the link

<a href="{{ token }}">;
Confirma tu email

this is the link url it generates:


In the check_email page I pick the token and send a post request to the controller:




And in the LoginController I have this function that picks the token and checks it:

async confirmEmail({response,request}){

    const token = request.only(['token'])

// tried also with 
// const realToken = await querystring.parse(token) 
// but I get realToken ={}

    const user = await Persona.verifyEmail(token)

    return response.send(user)


I’m having a ER_PARSE_ERROR in the verifyEmail function probably because the token gets corrupted somewhere.

Any idea on what I’m doing wrong?


1 Like

I solved using token.token on verifyEmail, just a little mistake.

async confirmEmail({response,request}){

    const token = request.only(['token'])

    const user = await Persona.verifyEmail(token.token)

    return response.send(user)

1 Like

Hi! Why did you use events for sending email? Is it easier way to send email directly in “register” method of UserController after registration, isn’t it?

You are right. It’s not needed, but I use it to keep the Controller with just the tasks it has to do. That’s why I use also hooks for other tasks. Just a matter of taste I think.

1 Like

@jorgeyoma Hi!

You can also do something like this :

const { token } = request.only(['token'])

so you can write token instead of token.token.

Also, you can delegate sending mail to a service and call it from your controller instead of using events, but as you said, it’s just a matter of taste.

1 Like