Hello, I have a vue frontend ang fastify backend. ...
# general
a
Hello, I have a vue frontend ang fastify backend. I was able to configure the emailpassword login. However, the revoke session seems to fail whenever I try to run the signout function. The verify session handler outputs that I am not authorized, even tho I can clearly see that the session ID is in the database.
r
hey @altristan
can you show me the requesyt headers for the API call that is failing?
a
Hi, these are the logs that I have. (Updated since it was a GET request previously, the updated snippet is now a POST request, although the issue still persists even though the status code is 200)
these are the request headers
Copy code
POST /auth/signout HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-US,en;q=0.9,fil;q=0.8
Connection: keep-alive
Content-Length: 0
Cookie: st-last-access-token-update=1709367703878; sFrontToken=eyJ1aWQiOiI2OTM4NWY2NS0zNWMxLTQwZGMtYmYwNi1kMDkxMWZkZmUwYTciLCJhdGUiOjE3MDkzNjgwMDMwMDAsInVwIjp7ImlhdCI6MTcwOTM2NzcwMywiZXhwIjoxNzA5MzY4MDAzLCJzdWIiOiI2OTM4NWY2NS0zNWMxLTQwZGMtYmYwNi1kMDkxMWZkZmUwYTciLCJ0SWQiOiJwdWJsaWMiLCJyc3ViIjoiNjkzODVmNjUtMzVjMS00MGRjLWJmMDYtZDA5MTFmZGZlMGE3Iiwic2Vzc2lvbkhhbmRsZSI6IjI5MmQ0MmEwLTVhOWItNDYwOS1hZmU5LWUyZWVjZTVmNzgzMiIsInJlZnJlc2hUb2tlbkhhc2gxIjoiZWQ5YjhlNTVjY2JiOTRhNWE1OWNlMTA0NDU3MjY2ODk2ZTFiNmM4YTUzYjkwOTY2NjdjYTQ3MDlhNjY0YmQ0NSIsInBhcmVudFJlZnJlc2hUb2tlbkhhc2gxIjpudWxsLCJhbnRpQ3NyZlRva2VuIjpudWxsLCJpc3MiOiJodHRwOi8vMTI3LjAuMC4xOjgwMDAvYXV0aCIsInN0LXJvbGUiOnsidiI6WyJDb250ZW50TWFuYWdlciJdLCJ0IjoxNzA5MzY3NzAzMjMxfSwic3QtcGVybSI6eyJ2IjpbImZpbGVzOnZpZXciLCJmaWxlczp1cGxvYWQiLCJmaWxlczpkb3dubG9hZCIsImZpbGVzOmVkaXQiLCJmaWxlczpkZWxldGUiLCJhcHA6Y3JlYXRlIiwiYXBwOnZpZXciLCJhcHA6ZWRpdCIsImFwcDpkZWxldGUiLCJyZXF1ZXN0czp2aWV3IiwicmVxdWVzdHM6YXBwcm92ZSIsInJlcXVlc3RzOmRlbnkiXSwidCI6MTcwOTM2NzcwMzQwMn19fQ==
Host: 127.0.0.1:8000
Origin: http://127.0.0.1:3000
Referer: http://127.0.0.1:3000/
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
@rp_st in my docker with postgres configuration, I set the refresh token validity to 10 mins and access token to 5 minutes. And upon testing, the session is revoked from the database at 10 minutes and then I have to login again. I was hoping to programmatically revoke the session from the database using the signout function as stated in the docs.
r
Can you show me the sign in api respond headers as well? A screenshot from chrome is needed
a
here it is
I think I figured it out. must be the issue with my URLs.
Am I right to assume that as long as the setup for the fastify plugin is configured, I do not have to recreate another custom /{apiBasePath}/signout on the backend? cause that's what I did in my setup. and the issue that the signout was not working before was that the frontend was configured with localhost as the url while the backend was configured with 127.0.0.1
r
u dont need to make another API for sign out
also, iin the screenshot, can you show me all the request headers?
and also a screenshot fo the response headers for the sign in API
a
here is the request headers for the sign in API
r
i need to see all the response headers for the api
a
signout API response headers
r
ok so the sign out API is working an expected
whats seems to be the issue here?
a
the issue was already fixed, thanks!. It was on my frontend and backend url configuration.
is it possible to programmatically assign a role to a user upon sign up? Am I correct that I should use the snippet below
Copy code
async function addRoleToUser(userId: string) {
    const response = await UserRoles.addRoleToUser("public", userId, "AppUser");
    console.log('add user role function: ', response);
    if (response.status === "UNKNOWN_ROLE_ERROR") {
        // No such role exists
        return;
    }

    if (response.didUserAlreadyHaveRole === true) {
        // The user already had the role
        return;
    }
}
into the frontend? I installed the supertokens-node into my vue frontend but is giving a buffer error
r
this needs to go in the backend, in the sign up override
3 Views