-
Notifications
You must be signed in to change notification settings - Fork 10
feat: allow users to sign up and fill out public forms #1114
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
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
1889e7d
first bad pass
tefkah d62f2b5
chore: merge
tefkah 827ca4c
feat: add invite table
tefkah 95d6d81
refactor: split up the signup code somewhat
tefkah 7e0ccdf
refactor: split up signup form into three forms
tefkah 19304b2
refactor: move public signup form to different place, do some checks
tefkah 437e87d
feat: add public join page
tefkah 8ecd5aa
fix: export invites
tefkah a90dda3
feat: add public signup stuff
tefkah 6b59061
chore: merge
tefkah 36e152d
feat: creaet happy path for unauthed signup
tefkah dbee4c3
feat: add user to pub after creation
tefkah 766df14
docs: add warning about foreign key issues
tefkah 5fd5b8b
chore: add todo comment
tefkah 7e50b0f
fix: set correct type for subitbuttons stageid
tefkah 2cb474e
fix: set correct type for stageId
tefkah cb9d39d
fix: no justify between for button formbuilder form
tefkah 0ee2557
fix: do not check authentication in public layout
tefkah 741bc0d
refactor: move join page to community signup page and make it work
tefkah a57ed77
refactor: auto log signup errors
tefkah 4c57700
dev: add a bunch of tests for the public form
tefkah 04d34e2
chore: remove signup service experiment
tefkah 0a65544
chore: remove next plugin bc it crashes vscode
tefkah 20b83ab
dev: fix tests by adding formcontrols around inputs
tefkah 9053549
fix: actually remove next plugin
tefkah dfed56c
fix: write some docs on how to deal with next's bullshit
tefkah dd433ab
feat: add ability to link to current pub and other places with markdo…
tefkah 50bc7c6
dev: more tests!
tefkah 4c19832
chore: update test
tefkah 7e7f8a1
fix: use maybeWithTransaction instead of directly creating transactio…
tefkah 7d99902
fix: remove superfluous test
tefkah 8b86f1f
fix: add authentication and add nicer submit button
tefkah f642721
fix: remove uneccesary tests
tefkah 3c87c16
fix: preserve redirect correctly
tefkah c05e26d
dev: add test for sign in behavior
tefkah 1e62278
chore: slightly dry out test
tefkah efae5f4
fix: slight improvements
tefkah 96720d3
fix: fix type error
tefkah d842f33
fix: give croccroc auto public form
tefkah 8ceb127
feat: remove invite only access type
tefkah 6b3d44a
fix: add data migration part
tefkah 0c321a8
fix: center signup form a bit
tefkah fcd721f
fix: actually add top margin
tefkah 78ab091
fix: grr forgot to save
tefkah 0d97bd2
Merge branch 'main' into tfk/public-form-users
tefkah af18745
fix: remove invite table for now
tefkah 343aeb8
Merge branch 'main' into tfk/public-form-users
tefkah ca84e1f
chore: merge
tefkah 23aa0b0
Merge branch 'main' into tfk/public-form-users
tefkah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
core/app/c/(public)/[communitySlug]/public/signup/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { notFound, redirect, RedirectType, unstable_rethrow } from "next/navigation"; | ||
|
|
||
| import { MemberRole } from "db/public"; | ||
| import { logger } from "logger"; | ||
|
|
||
| import { JoinCommunityForm } from "~/app/components/Signup/JoinCommunityForm"; | ||
| import { PublicSignupForm } from "~/app/components/Signup/PublicSignupForm"; | ||
| import { getLoginData } from "~/lib/authentication/loginData"; | ||
| import { findCommunityBySlug } from "~/lib/server/community"; | ||
| import { publicSignupsAllowed } from "~/lib/server/user"; | ||
|
|
||
| export default async function Page({ | ||
| params, | ||
| searchParams, | ||
| }: { | ||
| params: Promise<{ communitySlug: string }>; | ||
| searchParams: Promise<{ redirectTo?: string }>; | ||
| }) { | ||
| const [community, { user }] = await Promise.all([findCommunityBySlug(), getLoginData()]); | ||
|
|
||
| if (!community) { | ||
| logger.debug({ | ||
| msg: "Community not found on signup page", | ||
| communitySlug: (await params).communitySlug, | ||
| }); | ||
| notFound(); | ||
| } | ||
|
|
||
| const isAllowedToSignup = await publicSignupsAllowed(community.id); | ||
|
|
||
| if (!isAllowedToSignup) { | ||
| // this community does not allow public signups | ||
| notFound(); | ||
| } | ||
|
|
||
| const { redirectTo } = await searchParams; | ||
|
|
||
| if (user) { | ||
| if (user.memberships.some((m) => m.communityId === community.id)) { | ||
| redirect(redirectTo ?? `/c/${community.slug}/stages`); | ||
| // TODO: redirect to wherever they were redirected to before signing up | ||
| throw new Error("User is already member of community"); | ||
| } | ||
|
|
||
| // TODO: figure this out based on the invite | ||
| const joinRole = MemberRole.contributor; | ||
|
|
||
| return ( | ||
| <Wrapper> | ||
| <JoinCommunityForm community={community} role={joinRole} redirectTo={redirectTo} /> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Wrapper> | ||
| <PublicSignupForm communityId={community.id} redirectTo={redirectTo} /> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * just a wrapper that centers stuff on the page. | ||
| * could be put in a layout later | ||
| */ | ||
| const Wrapper = ({ children }: { children: React.ReactNode }) => { | ||
| return ( | ||
| <div className="m-auto mt-16 flex min-h-[50vh] max-w-lg flex-col items-center justify-center"> | ||
| {children} | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,23 +8,17 @@ import { Contact, Lock, Users } from "ui/icon"; | |
| import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "ui/select"; | ||
|
|
||
| const iconsAndCopy = { | ||
| [FormAccessType.inviteOnly]: { | ||
| Icon: Contact, | ||
| description: "Accessible via URL with tracked submissions", | ||
| name: "Invite Only", | ||
| help: "Community members & invited contributors can submit", | ||
| }, | ||
|
Comment on lines
-11
to
-16
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per the extra work in #1051 , we now only have private and public forms |
||
| [FormAccessType.private]: { | ||
| Icon: Lock, | ||
| description: "Only accessible via Pub editor", | ||
| name: "Private", | ||
| help: "Only community members can create and edit", | ||
| help: "Only community members or invitees can create and edit", | ||
| }, | ||
| [FormAccessType.public]: { | ||
| Icon: Users, | ||
| description: "Accessible via URL with untracked submissions", | ||
| name: "Public", | ||
| help: "Anyone with the link can submit", | ||
| help: "Anyone with the link can signup can submit. NOTE: this enables public signups to your community.", | ||
| }, | ||
| }; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 removal doesn't really do anything other than make me feel better.