rp
04/26/2022, 6:54 AMyzs
04/26/2022, 7:27 AMattemptRefreshingSession
and doesSessionExist
keep returning false
ts
const api = axios.create({ baseURL: '/api', timeout: 5_000 });
SuperTokens.addAxiosInterceptors(api);
SuperTokens.init({
apiDomain: 'http://localhost:3000',
apiBasePath: '/api/auth',
});
async function signIn(form) {
const res = await api.post('/auth/signin', form);
// {"status":"OK","user":{"email":"test@gmail.com","id":"de770ff7-4524-4108-994f-717c1d12bec4","timeJoined":1650956757303}}
// the set-cookie headers are also present, and cookies are saved correctly
const attemptRefreshingSession = await SuperTokens.attemptRefreshingSession();
const doesSessionExist = await SuperTokens.doesSessionExist()
console.log(attemptRefreshingSession, doesSessionExist); // false, false
}
yzs
04/26/2022, 7:30 AMreq.session
is undefined
on all requests after signinrp
04/26/2022, 7:56 AMyiannis.gkoufas
04/26/2022, 8:03 AMemailpassword_email_exists_get
method (as I understand)
the thing I am not sure about is how to query the db about a user with a specific email.
I found this code in the source:
params = {
'email': email
}
response = await Querier.get_instance("random").send_get_request(NormalisedURLPath('/recipe/user'), params)
if 'status' in response and response['status'] == 'OK':
return User(response['user']['id'], response['user']
['email'], response['user']['timeJoined'])
however it doesn't return the user I expect to findrp
04/26/2022, 8:21 AMrp
04/26/2022, 8:23 AMyiannis.gkoufas
04/26/2022, 8:48 AMyiannis.gkoufas
04/26/2022, 8:52 AMyiannis.gkoufas
04/26/2022, 8:56 AMFrAgOrDiE
04/26/2022, 11:29 AMts
@Injectable()
export class GQLAuthGuard implements CanActivate {
async canActivate(context: ExecutionContext): Promise<boolean> {
const ctx = GqlExecutionContext.create(context).getContext();
let err = undefined;
// You can create an optional version of this by passing {sessionRequired: false} to verifySession
await verifySession({ sessionRequired: false })(
ctx.req,
ctx.res,
(res) => {
err = res;
},
);
if (ctx.res.headersSent) {
throw new STError({
message: 'RESPONSE_SENT',
type: 'RESPONSE_SENT',
});
}
if (err) {
throw err;
}
return true;
}
}
yzs
04/26/2022, 11:33 AMrp
04/26/2022, 11:33 AMgitcommitshow
04/27/2022, 5:07 AMonHandleEvent
for supertokens-website
. Here's what I did
1. I logged out the user using await supertokens.signOut();
2. I added onHandleEvent
as following
supertokens.init({
apiDomain: "...",
onHandleEvent: (context) => {
if (context.action === "UNAUTHORISED") {
alert("You are not logged in");
if (context.sessionExpiredOrRevoked) {
console.log("Session expired or revoked")
}
}
}
})
But I don't see any alert or console logshorthair_[]
04/27/2022, 6:18 AMshorthair_[]
04/27/2022, 6:18 AMshorthair_[]
04/27/2022, 6:18 AMshorthair_[]
04/27/2022, 6:19 AMshorthair_[]
04/27/2022, 6:19 AMshorthair_[]
04/27/2022, 6:19 AMshorthair_[]
04/27/2022, 6:20 AMshorthair_[]
04/27/2022, 6:21 AMshorthair_[]
04/27/2022, 6:21 AMrp
04/27/2022, 6:35 AMcors_allow_headers
in your CORS setting anyway.M/\X
04/27/2022, 7:05 AMscherbatsky.jr
04/27/2022, 9:29 AMrp
04/27/2022, 9:30 AMrp
04/27/2022, 9:30 AMscherbatsky.jr
04/27/2022, 9:50 AM