I’m in process of learning the JWT functionality with Rainlab.User plugin
So far everything is ok with account creation and login. I get the token and next I’m trying to get the user data from an endpoint.
The request goes like this:
axios.get('/api/account/user', {
headers: {
Authorization: 'Bearer ' + token
}
}).then(response => {
console.log(response.data);
});
Next, I’ve set the layout as specified in the documentation:
description = "Auth API Layout"
is_priority = 1
[session]
checkToken = 1
[account]
==
{% if session %}
{% page %}
{% else %}
{% do response({error: 'Access Denied'}, 403) %}
{% endif %}
and the user endpoint:
url = "/account/user"
layout = "auth"
title = "user"
[account]
==
{% do response({
token: session.token,
session: session.user,
account: account.user,
user: user
}) %}
But on that endpoint I’m not getting any data.
session.user is null, account.user is null and so on.
I don’t understand what am I doing wrong here.