Skip to content
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/site creation form email #679

Merged
merged 8 commits into from
Apr 10, 2023
Merged

Conversation

alexanderleegs
Copy link
Contributor

This PR modifies our existing site creation form to utilise the new email login flow instead. Currently, our site creation form creates a new website, but does not assign site members to the new site - thus our creation flow currently creates an Amplify site that is accessed via Github login, with access manually granted to users via Github. This PR changes the creation flow to associate an existing isomer user to the specified site, or create a new isomer user using the specified email if no such user exists. A new form has also been created for both staging and production (staging form link). Note that the person filling in the form is still specified as the owner of the form.

Env var changes before merging:

  • Modify SITE_CREATE_FORM_KEY on production - we're using a new site create form (v3) just to be safe, so the form key needs to be swapped out to the new secret key

@alexanderleegs alexanderleegs requested a review from a team April 5, 2023 02:26
Copy link
Contributor

@kishore03109 kishore03109 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an example of a repo that has been created via this new form as a sanity check that this works?

src/routes/formsgSiteCreation.ts Outdated Show resolved Hide resolved
src/routes/formsgSiteCreation.ts Show resolved Hide resolved
src/services/infra/InfraService.ts Outdated Show resolved Hide resolved
src/services/infra/InfraService.ts Show resolved Hide resolved
const foundUser = await this.usersService.findByEmail(requesterEmail)
if (!foundUser) {
const foundRequester = await this.usersService.findByEmail(requesterEmail)
if (!foundRequester) {
const err = `Form submitter ${requesterEmail} is not an Isomer user. Register an account for this user and try again.`
await this.sendCreateError(requesterEmail, repoName, submissionId, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry a bit confused, this is an error flow right? Why are we returning 200 res after sendCreateError?

Copy link
Contributor Author

@alexanderleegs alexanderleegs Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint is only triggered by forms, which expects a 200 response, otherwise it could trigger a retry! The error handling is done separately via email

@@ -51,6 +52,7 @@ export class FormsgRouter {
const requesterEmail = getField(responses, REQUESTER_EMAIL_FIELD)
const siteName = getField(responses, SITE_NAME_FIELD)
const repoName = getField(responses, REPO_NAME_FIELD)
const ownerEmail = getField(responses, OWNER_NAME_FIELD)?.toLowerCase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could we do a strip on the string?
worried if ops put space then the string equality operation fails and it registers as new email
(maybe this error case is captured downstream)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, added in 80cfbbd

@alexanderleegs alexanderleegs merged commit d7e2788 into develop Apr 10, 2023
@mergify mergify bot deleted the feat/site-creation-form-email branch April 10, 2023 06:28
alexanderleegs added a commit that referenced this pull request Apr 11, 2023
* Feat: add findOrCreateByEmail

* Feat: add site member instead of github team

* Feat: update forms parsing

* Fix: update infraService initialisation

* Chore: remove unused createTeamOnGithub

* nit: update variable name

* chore: update todo with issue number

* Fix: trim user input
@kishore03109 kishore03109 mentioned this pull request Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants