Hello @luke , thanks for helping me out here!
So I believe redirects are now working properly (ended up using a _redirects file but the TOML approach worked as well. I deployed a new test site using Hugo (easier for me to use for testing) which you can check out here: https://hungry-chandrasekhar-ced2a7.netlify.com/. The login button is at the top left sandwiched between the two logos (I haven’t bothered cleaning-up anything until I can the overall redirect/role working). The non-logged in behavior works as expected, when you click on “Docs” in the top-right nav it brings you to “Blog”. The problem is it does the same thing when you are logged in. This leads me to think I am now facing a problem around the identity aspect.
I know the sign-up process is working fine and is properly assign the role of “member” as I can see it automatically assigned in the Identity setting panel:
Oddly enough when I re-deploy the site, I am sometimes still logged in and the redirect logic works: it will let me access “Docs” just fine. However as soon as I log out and log back in, I can no longer access “Docs” and keep on being redirected to “Blog”.
Git repo: https://github.com/antoinejuhel/hugo-test
My _redirects file:
/docs/* 200! Role=member
/docs/* /blog/ 401!
More info on my setup:
I am using a function called “identity-validate.js” which contains the following:
exports.handler = function(event, context, callback) {
const data = JSON.parse(event.body);
const { user } = data;
const responseBody = {
app_metadata: {
authorization: {
roles: ["member"]
}
my_user_info: "Logged in user"
},
};
callback(null, {
statusCode: 200,
body: JSON.stringify(responseBody)
});
};
I have also checked that I in fact get a nf_jwt JWT when I log in, and decoded it to find the following payload which seems to indicate that is working as expected:
{
"exp": 1574719311,
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1NzQ3MTkzMTEsInN1YiI6IjNiNmUxNTYyLTE2MTgtNDg5NS04NDc1LTljZjRkZmY5MjU2ZiIsImVtYWlsIjoiYW50b2luZWp1aGVsQGdtYWlsLmNvbSIsImFwcF9tZXRhZGF0YSI6eyJyb2xlcyI6WyJtZW1iZXIiXX0sInVzZXJfbWV0YWRhdGEiOnsiZnVsbF9uYW1lIjoiQW50b2luZSJ9fQ.GQDafdkdteI7Li-elWMcycsK0s5FMholHMV5l7yatw8sub": "3b6e1562-1618-4895-8475-9cf4dff9256f",
"email": "antoinejuhel@gmail.com",
"app_metadata": {
"roles": [
"member"
]
},
"user_metadata": {
"full_name": "Antoine"
}
}
I know this has now deviated from the original redirect issue so please let me know if I should post this somewhere else.
Thanks again,
Antoine