lavenderlav
04/30/2022, 3:41 PMts
import * as stSessions from "supertokens-auth-react/recipe/session";
stSessions.init();
but it seems to still not workrp
04/30/2022, 3:42 PMlavenderlav
04/30/2022, 3:48 PMlavenderlav
04/30/2022, 3:48 PMrp
04/30/2022, 3:49 PMlavenderlav
04/30/2022, 3:49 PMts
const SessionAuthNoSSR = dynamic(
new Promise<any>((res) =>
res(SessionRecipe.SessionAuth)
),
{ ssr: false }
)
return (
<SessionAuthNoSSR>
props here
</SessionAuthNoSSR>
)
lavenderlav
04/30/2022, 4:01 PMCuriousCI
04/30/2022, 5:10 PMclass DonationViewSet(viewsets.ModelViewSet):
queryset = Donation.objects.all()
serializer_class = DonationSerializer
@verify_session()
async def get_queryset(self):
session: SessionContainer = self.request.supertokens
user_id = session.get_user_id()
return Donation.objects.filter(user_id_id=user_id)
'coroutine' object is not iterable
edit 1
I fixed this problem, I had to import verify_session from syncio, not asyncio, and remove the async keyword, but I got into another problem: verify_session is looking for the parameter request, but it is inside 'self'
edit 2
I copied the implementetion of verify_session for Django, and it works
edit 3
The best solution I found was creating another function inside the function to verify the session and return it (with @verify_session()), much cleaner
class DonationViewSet(viewsets.ModelViewSet):
queryset = Donation.objects.all()
serializer_class = DonationSerializer
def get_queryset(self):
@verify_session()
def verify(request):
return request.supertokens
session = verify(self.request)
user_id = session.get_user_id()
return Donation.objects.all(user_id_id=user_id)
I wrote this process, for everyone using Django REST framework like in my case.gitcommitshow
04/30/2022, 6:42 PMverifySession
middleware.
When the token is expired, it sends 401 response with json response {"message":"try refresh token"}
.
Instead of this, I want to send an html page.
So I decided to use onUnAuthorised
event in SuperTokens node sdk.
Session.init({
errorHandlers: {
onUnauthorised: async (message, request, response) => { console.log(message);
// But this didn't print anything
},
....
To test the fn, I logged but I didn't see anything printed in console.
1. Am I using 'onUnAuthorised' event correctly?
2. Is 'onUnAuthorised` event the correct place to override the behaviour on token expiry? Do we have any example or reference for this event?rp
05/01/2022, 5:35 AMgitcommitshow
05/01/2022, 6:46 AMrp
05/01/2022, 8:09 AMravaelamanov
05/01/2022, 10:49 AMCuriousCI
05/01/2022, 11:32 AMrp
05/01/2022, 12:26 PMrp
05/01/2022, 12:27 PMgitcommitshow
05/01/2022, 12:46 PMgitcommitshow
05/02/2022, 1:25 AMSession.refreshToken
does?
How to find the references of this function. The SDK reference doesn't say much about it https://supertokens.com/docs/nodejs/modules/recipe_session.html#refreshSession-1solminded
05/02/2022, 1:33 AMCould not refresh session
error.gitcommitshow
05/02/2022, 2:24 AMXxX_MLG Noob_XxX
05/02/2022, 3:45 PMSuperTokens
support regular form HTTP posts? (As opposed to using json-ified data)XxX_MLG Noob_XxX
05/02/2022, 4:41 PMverifySession
still work correctly? π€ Even when I set sessionRequired: false
, I'm getting 401s.[Manicraft1001]
05/03/2022, 9:38 AMtypescript
const initSuperTokens = () => {
supertokens.init({
framework: "express",
supertokens: {
connectionURI: "REDACTED",
apiKey: "REDACTED",
},
appInfo: {
appName: "REDACTED",
apiDomain: "http://localhost:3000",
websiteDomain: "http://localhost:3000",
apiBasePath: "/api/authentication",
websiteBasePath: "/authentication",
},
recipeList: [
ThirdPartyEmailPassword.init({
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,
emailPasswordSignUpPOST: async function (input) {
if (
originalImplementation.emailPasswordSignUpPOST === undefined
) {
throw Error("Should never come here");
}
// First we call the original implementation
let response =
await originalImplementation.emailPasswordSignUpPOST(input);
console.log("response");
console.log(response);
// If sign up was successful
if (response.status === "OK") {
// We can get the form fields from the input like this
let formFields = input.formFields;
let user = response.user;
console.log(formFields);
console.log(user);
// TODO: register user in the database
// some post sign up logic
}
return response;
},
};
},
},
}),
Session.init(), // initializes session features
],
});
};
export default initSuperTokens;
NicolaiVdS
05/03/2022, 10:07 AMpsql:
image: postgres
container_name: postgress
restart: unless-stopped
ports:
- "5432:5432"
volumes:
- ./docker/psql/data:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
supertokens:
image: registry.supertokens.io/supertokens/supertokens-postgresql
container_name: supertokens
restart: unless-stopped
ports:
- 3567:3567
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRESQL_DATABASE_NAME: ${POSTGRES_DB}
depends_on:
- psql
and yes i started the db firstwdjzr
05/03/2022, 1:56 PM192.168.1.16
as the psql hostwdjzr
05/03/2022, 1:56 PMwdjzr
05/03/2022, 1:56 PM192.168.1.16
outside the docker and it works without any issueswdjzr
05/03/2022, 1:57 PMcodingtomato
05/03/2022, 2:28 PMrp
05/03/2022, 5:31 PMrp
05/03/2022, 5:31 PM