pvharmo
04/29/2022, 1:25 PMrp
04/29/2022, 1:26 PMrp
04/29/2022, 1:27 PMMnove
04/29/2022, 1:51 PMWildson
04/29/2022, 3:05 PMkedw
04/29/2022, 9:59 PM/auth/verify-email
route myself? Right now I'm getting a 404 when I click the email link.nkshah2
04/30/2022, 3:47 AMnoxy
04/30/2022, 9:07 AMrp
04/30/2022, 9:17 AMsolminded
04/30/2022, 1:47 PMlavenderlav
04/30/2022, 3:38 PMsupertokens-auth-react/recipe/session
initialization need any arguments? it seems to say No instance of Session found
even when I called (supertokens-auth-react/recipe/session).init()
rp
04/30/2022, 3:40 PMrp
04/30/2022, 3:40 PMlavenderlav
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 PM