-
Notifications
You must be signed in to change notification settings - Fork 263
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
Fixes #61: Added an option to create user on the dashboard's "User" section #64
Conversation
@kabir276 is attempting to deploy a commit to the Stackframe Team on Vercel. A member of the Team first needs to authorize it. |
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.
Thanks for the contribution!
type CreateDialogProps = { | ||
open: boolean; | ||
onOpenChange: (open: boolean) => void; | ||
opennotification: Function |
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.
Instead of passing up a function like this, can you put the notifyPassword dialog into ?
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.
How about this
setShowNotifyPasswordDialog: React.Dispatch<React.SetStateAction>;
instead of
onOpenChange: (open: boolean) => void;
Will this work?
const stackAdminApp = useAdminApp(); | ||
const allUsers = stackAdminApp.useServerUsers(); | ||
|
||
const [addUserOpen, setAddUserOpen] = React.useState(false); | ||
const [notifyPassword, setNotifyPassword] = React.useState(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.
const [notifyPassword, setNotifyPassword] = React.useState(false); | |
const [showNotifyPasswordDialog, setShowNotifyPasswordDialog] = React.useState(false); |
packages/stack-server/src/app/(main)/(protected)/projects/[projectId]/users/page-client.tsx
Show resolved
Hide resolved
@@ -638,6 +638,33 @@ export class StackClientInterface { | |||
}); | |||
} | |||
|
|||
async createUser( |
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.
There is some code duplication between this and signUpWithCredential
now. Can we make the latter call this function?
packages/stack/src/lib/stack-app.ts
Outdated
@@ -778,6 +778,20 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin | |||
} | |||
return errorCode; | |||
} | |||
|
|||
async createUser(options: { |
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.
There is some code duplication between this and signUpWithCredential now. Can we make the latter call this function?
packages/stack/src/lib/stack-app.ts
Outdated
if (!errorCode) { | ||
console.log("done") | ||
} |
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.
if (!errorCode) { | |
console.log("done") | |
} |
|
||
const [addUserOpen, setAddUserOpen] = React.useState(false); | ||
const [notifyPassword, setNotifyPassword] = React.useState(false); | ||
console.log(notifyPassword) |
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.
console.log(notifyPassword) |
packages/stack/src/lib/stack-app.ts
Outdated
@@ -1759,6 +1773,7 @@ export type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId ex | |||
|
|||
signInWithOAuth(provider: string): Promise<void>, | |||
signInWithCredential(options: { email: string, password: string }): Promise<KnownErrors["EmailPasswordMismatch"] | undefined>, | |||
createUser(options: { email: string }): Promise<KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>, |
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.
This function should return the generated password.
Do you have any thoughts on whether createUserWithCredential is a better name for this? Since theoretically a user could be a different type as well (OAuth, magic link, etc). Maybe @fomalhautb you have an opinion on this?
Fixes Issue #61
Description
I've added an option to create users on the dashboard's "Users" section. I've created a pull request for your review. Please let me know if this is what you envisioned. If not, I'm happy to make further adjustments.
Changes Made
Updated users>page.client.tsx , lib>stack-app.ts , Interface>clientInterface.ts to include the button to create users.
Additional Notes
No new dependencies were added.