Rasel Hossain
Rasel Hossain
Explore posts from servers
KKinde
Created by Rasel Hossain on 11/5/2024 in #💻┃support
Bulk update feature flag by user email.
ok @Claire_Kinde
4 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
ok @Peteswah
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
are you talking about withAuth(req). we are not using it.
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
no problem @Claire_Kinde . take your time
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
Hay @Peter (Kinde) it does not work
22 replies
KKinde
Created by James on 5/28/2024 in #💻┃support
Kinde + tRPC + NextJS app router
Hi James, did you find any solutions? I am encountering the same issue; they did not write the blog correctly
7 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
Protected Procedure :
// Protected Procedure
export const protectedProcedure = t.procedure.use(async ({ ctx, next }) => {
const isAuthenticated = ctx.isAuthenticated;
if (!isAuthenticated || ctx.session === null) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "User is not authenticated",
});
}

const session = ctx.session;


return next({
ctx: {
...ctx,
session,
},
});
});
// Protected Procedure
export const protectedProcedure = t.procedure.use(async ({ ctx, next }) => {
const isAuthenticated = ctx.isAuthenticated;
if (!isAuthenticated || ctx.session === null) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "User is not authenticated",
});
}

const session = ctx.session;


return next({
ctx: {
...ctx,
session,
},
});
});
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
Hay @Peter (Kinde) . I've implemented it as you suggested, but I forgot to mention that I'm using TRPC for the API. Do I need to make any changes to the TRPC context? Below is a sample of my TRPC context and Protected procedure, as I'm encountering an error saying 'User is not authenticated' from the protected procedure
export const createTRPCContext = async () => {
const { isAuthenticated } = getKindeServerSession();
const isUserAuthenticated = await isAuthenticated();

// If user is not authenticated, return null session
if (!isUserAuthenticated) {
return {
db: DBClient,
session: null,
isAuthenticated: false,
};
}

const session = await getUserSession();

return {
session,
db: DBClient,
isAuthenticated: true,
};
};

export type TRPCContext = typeof createTRPCContext;
export const createTRPCContext = async () => {
const { isAuthenticated } = getKindeServerSession();
const isUserAuthenticated = await isAuthenticated();

// If user is not authenticated, return null session
if (!isUserAuthenticated) {
return {
db: DBClient,
session: null,
isAuthenticated: false,
};
}

const session = await getUserSession();

return {
session,
db: DBClient,
isAuthenticated: true,
};
};

export type TRPCContext = typeof createTRPCContext;
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
Hello @Claire_Kinde after updating the Kinde npm version, I received the refreshTokens property from the getKindeServerSession(). However, I am facing a window refreshing issue. Below, I am writing the details about it. We're using Kinde as the authentication provider in our application, which includes a quiz feature where users are not allowed to reload their tab during the quiz to prevent cheating. We are currently facing an issue with the refresh token. I've limited the access token to 5 minutes in the Kinde admin dashboard. On the server side, I'm using the following code to refresh tokens:
const { refreshTokens } = await getKindeServerSession();
await refreshTokens();
const { refreshTokens } = await getKindeServerSession();
await refreshTokens();
On the client side, I am using the following code:
const { getToken } = useKindeBrowserClient();
getToken();
const { getToken } = useKindeBrowserClient();
getToken();
We are using the latest Next.js SDK from Kinde. As mentioned earlier, when the quiz starts, users are not allowed to reload the window. If the window is reloaded, it could result in cheating, which we want to prevent. However, when refreshTokens() or getToken() is invoked, the page reloads to refresh the access token. Our requirement is to refresh the access token silently in the background without reloading the page. We haven’t been able to find a solution to this issue yet. Could you please guide us on how to handle this scenario with Kinde?
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
No description
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
No description
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
Could you please share some resources or documents about the implementation?
22 replies
KKinde
Created by Rasel Hossain on 10/22/2024 in #💻┃support
I redirect to the login page after my access token expires.
I want to automatically refresh the access token behind the scenes, so users are not repeatedly redirected to the login page. My access token expires in one day.
22 replies
TtRPC
Created by Rasel Hossain on 4/30/2024 in #❓-help
Handle Multipart form data.
thanks Alex
5 replies
TtRPC
Created by Igor_lviv on 5/10/2023 in #❓-help
How to upload file not use S3 Next js? Please, example
did you find any solution?
4 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
I have already read it, but I did not find any solution.
10 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
@Sandvich
10 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
No description
10 replies
TtRPC
Created by Rasel Hossain on 4/9/2024 in #❓-help
How to get the Request Body data of QStash
thanks Sandvich
10 replies
TtRPC
Created by TaylorFay on 10/10/2023 in #❓-help
how to access body in middleware
No description
4 replies