Güzel bir sorum var hocam biz jwt'yi eğer backend üzerinden gönderilen jwt olarak ayarlamak istiyorsak ve bu session'ın expire zamanını'da backend üzerinden gelen veri ile düzenlemek istiyorsak ne yapmamız gerekiyor ? session:{ jwt:true, maxAge:30 * 24 * 60 * 60, //30 gün },
@FatihBaytar7 ай бұрын
Güzel soru. Webapi den çekilen verileri decrypte etmek gerekecek. Bunun için webapi deki secret key ile işlem yapılması gerekiyor. Bunla ilgili bir örnek yapabiliriz
@kubilaybzk7 ай бұрын
@@FatihBaytar decrypte etmek yerine doğrudan api ile responce ederken session ile beraber yollarsak daha mantıklı olur diye düşünüyorum ama tek problem bu gelen date verisini nextAuth'da nereye assign edeceğimiz :) oldukça fazla arama yaptım chatgpt vs buralara sordum fakat istediğim cevabı bulamadım
@FatihBaytar7 ай бұрын
@kubilaybzk next-auth.js.org/configuration/options burada dökümanında seçenek sunmuşlar
@kubilaybzk7 ай бұрын
@@FatihBaytar Evet buna bende baktım hocam, async session({ token, session }): Promise { session.user.name = token.userInfo.nameSurname; session.user.email = token.userInfo.email; session.user.userName = token.userInfo.userName; session.accessToken = token.accessToken; session.expiration = token.expiration; const currentDate = new Date(); const expirationDate = new Date(token.expiration); if (currentDate < expirationDate) { // Token hala geçerli ise oturumu güncelle console.log("SÜRE DOLMADI "); return session; } else { // Token süresi dolmuşsa kullanıcıyı uygulamadan çıkış yapmasını sağla console.log("SÜRE DOLDU "); if (!session || !token) { // Assuming you are using Express.js for server-side rendering, you can set the cookies to expire immediately // Add any other cookies you might be using for session management } return null; } }, Böyle bir çözüm bulmuştum , ama her route değişmesinde vs çalışıyor kendisi arka planda ufak bir condition döndürüyor ama herhangi bir route değişez ise session silinmiyor malesef .
@kubilaybzk7 ай бұрын
@@FatihBaytar Bu dökümanı incelemiştim hocam, Söyle bir çözü bulmuştum async session({ token, session }): Promise { session.user.name = token.userInfo.nameSurname; session.user.email = token.userInfo.email; session.user.userName = token.userInfo.userName; session.accessToken = token.accessToken; session.expiration = token.expiration; const currentDate = new Date(); const expirationDate = new Date(token.expiration); if (currentDate < expirationDate) { // Token hala geçerli ise oturumu güncelle console.log("SÜRE DOLMADI "); return session; } else { // Token süresi dolmuşsa kullanıcıyı uygulamadan çıkış yapmasını sağla console.log("SÜRE DOLDU "); if (!session || !token) { // Assuming you are using Express.js for server-side rendering, you can set the cookies to expire immediately // Add any other cookies you might be using for session management } return null; } },