-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(platform): Create ui link for resend otp #489
feat(platform): Create ui link for resend otp #489
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good, just you need to organise the API call in the right file
const handleResendOtp = async (userEmail: string): Promise<void> => { | ||
try { | ||
setIsLoadingRefresh(true) | ||
const response = await fetch( | ||
`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/resend-otp/${encodeURIComponent(userEmail)}`, | ||
{ | ||
method: 'POST' | ||
} | ||
) | ||
if (response.status === 429) { | ||
toast.error("Couldn't send OTP, too many requests") | ||
setIsLoadingRefresh(false) | ||
} else if (response.ok) | ||
toast.success('OTP successfully sent to your email') | ||
setIsLoadingRefresh(false) | ||
} catch (error) { | ||
// eslint-disable-next-line no-console -- we need to log the error | ||
console.error(`Failed to send OTP: ${error}`) | ||
toast.error("Couldn't send OTP .") | ||
setIsLoadingRefresh(false) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you organize the API logic in apps/platform/src/lib/api-functions
rest looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use your own calls to the API. Rather use this:
keyshade/packages/api-client/src/controllers/user.ts
Lines 55 to 65 in 5884833
async resendEmailChangeOTP( | |
request: ResendEmailChangeOTPRequest, | |
headers?: Record<string, string> | |
): Promise<ClientResponse<ResendEmailChangeOTPResponse>> { | |
const response = await this.apiClient.post( | |
`./api/user/resend-email-change-otp`, | |
request, | |
headers | |
) | |
return await parseResponse<ResendEmailChangeOTPResponse>(response) | |
} |
You can check the usage of these in any of the CLI files: https://github.com/keyshade-xyz/keyshade/tree/develop/apps/cli/src/commands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resendEmailChangeOTP
I got the point of the controller code from api-client but not the second thing you said
You can check the usage of these in any of the CLI files: https://github.com/keyshade-xyz/keyshade/tree/develop/apps/cli/src/commands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I meant that you can check any of the files in the commands
directory to understand how to use these controllers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i have to write a new controller for auth and utilise as a controller instance if I am getting it right?
Is there a controller instance file similar instance to https://github.com/keyshade-xyz/keyshade/blob/develop/apps/cli/src/util/controller-instance.ts or I need to create one for the frontend of platform?
Can you please point that file if possible it would be helpful thanks. |
32ea02b
to
017828c
Compare
I have mentioned the file in the review |
We shouldn't be using a separate api function folder, we already have a dedicated package for that. |
Looks like I need to migrate some stuffs |
@kriptonian1 @Prakhargarg-2010196 lmk when this is ready |
017828c
to
e908b20
Compare
I am working on the changes but was bit confused |
Let the api-client.ts file be. You would need to use the one from |
@Prakhargarg-2010196 can you please configure ESLint on your device to use the config from keyshade? There are linting errors |
That's what I was saying the errors are not being thrown locally when i run Can you tell me some way to know which config is being consumed |
Okay got it. I'll switch to your PR and check it manually |
- Created new controller instance for better management of API interactions. - Added authentication controller in API client for handling OTP-related requests. - Introduced type definitions for authentication to improve type safety. - Renamed index types definition for consistency.
150d88f
to
4b7d912
Compare
@kriptonian1 if you can lend me a hand then it would be awesome |
@Prakhargarg-2010196 I have relaxed the restrictions on ESLint |
You can ignore the lint failure, that's probably false. |
Then merge can be done right ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
## [2.7.0](v2.6.0...v2.7.0) (2024-11-05) ### 🚀 Features * **cli:** Add functionality to operate on Variables ([#514](#514)) ([32d93e6](32d93e6)) * **platform:** Create ui link for resend otp ([#489](#489)) ([46eb5c5](46eb5c5)) ### 🐛 Bug Fixes * **api,api-client:** Add environmentSlug in multiple places across the [secure] module ([#509](#509)) ([ee58f07](ee58f07)) * **cli:** Removed unnecessary console log in [secure]s ([#515](#515)) ([9403cc4](9403cc4)) ### 🔧 Miscellaneous Chores * Fixed lint issues ([835397a](835397a)) * Minor housekeeping ([922bf31](922bf31)) * Update eslint ([c583718](c583718)) * Update eslint ([7c0c596](7c0c596)) * Update pnpx commands to pnpm dlx ([#511](#511)) ([534a231](534a231))
🎉 This PR is included in version 2.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
User description
Description
Adding the link to platform ui for resending otp
Fixes #479
Screenshots of relevant screens
Developer's checklist
If changes are made in the code:
PR Type
Enhancement
Description
handleResendOtp
to manage the resend OTP process, including API call and error handling.Changes walkthrough 📝
page.tsx
Implement resend OTP functionality in authentication page
apps/platform/src/app/auth/otp/page.tsx
handleResendOtp
function to handle OTP resend logic.