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

Account creation #48

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Account creation #48

wants to merge 19 commits into from

Conversation

adic2023
Copy link
Contributor

@adic2023 adic2023 commented Oct 3, 2023

Resolves #37.

@RobinsonZ
Copy link
Member

Also, ignore the broken tests—I need to get around to fixing them after the rate-limiting addition broke them (because firing off a bunch of POST requests in a short timeframe trips the ratelimiter, and that's exactly what the integration testing does)

Copy link
Member

@RobinsonZ RobinsonZ left a comment

Choose a reason for hiding this comment

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

Additionally, you're probably going to want to update the isEmailAvailable function, adding another existence check here to make sure the email doesn't exist in the VerifyEmailRequestModel database.

src/functions/createAccount.ts Outdated Show resolved Hide resolved
src/routes/account.ts Outdated Show resolved Hide resolved
Comment on lines +120 to +123
suppressEmail: {
type: Boolean,
required: false,
},
Copy link
Member

Choose a reason for hiding this comment

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

This isn't necessary for email verification requests, since there isn't really a "confirmation" of the email being verified like there is for password resets. We have this option in the password reset model because there's two scenarios where we do a password reset: 1) explicitly creating a new account and 2) a user-requested password reset. In scenario 2 we send a confirmation email after the change happens (see here), but not in scenario 1.

Copy link
Member

Choose a reason for hiding this comment

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

Wait, why was this marked as resolved? This hasn't been fixed.

src/integration/models.ts Outdated Show resolved Hide resolved
+sauce-layout('Your request has been submitted!')(hideNavbar, includeBootstrapScripts)
h1.mb-4 We've sent you an email, follow the instructions to complete setting up your SCCS account
p.
To prevent abuse, SCCS staff manually approve all account creation
Copy link
Member

Choose a reason for hiding this comment

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

This isn't true anymore with these new changes!

(But also, don't worry about this, I'll write some copy here. This is more for my own note)

@@ -280,6 +280,7 @@ export const isEmailAvailable = async (email: string): Promise<boolean> => {
const [inDatabase, inPending] = await Promise.all([
Copy link
Member

Choose a reason for hiding this comment

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

I realize this code needs slightly more tweaking - needs to capture the results in three different variables

Suggested change
const [inDatabase, inPending] = await Promise.all([
const [inDatabase, inPending, inNeedsVerify] = await Promise.all([

@@ -280,6 +280,7 @@ export const isEmailAvailable = async (email: string): Promise<boolean> => {
const [inDatabase, inPending] = await Promise.all([
searchAsync(ldapClient, ldapEscape.filter`(swatmail=${email})`),
TaskModel.exists({ 'data.email': email, status: 'pending' }),
VerifyEmailRequestModel.exists({ 'data.email': email }),
]);

if (inDatabase || inPending) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (inDatabase || inPending) {
if (inDatabase || inPending || inNeedsVerify) {

Comment on lines +120 to +123
suppressEmail: {
type: Boolean,
required: false,
},
Copy link
Member

Choose a reason for hiding this comment

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

Wait, why was this marked as resolved? This hasn't been fixed.

Comment on lines 11 to 12
input(type='hidden', name='id', value=id)
input(type='hidden', name='key', value=key)
Copy link
Member

Choose a reason for hiding this comment

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

The createAccount page itself (the one that doesn't contain Cygnet data) doesn't need id and key hidden form parameters. Those will go in the other page that requires you to actually click a reset link.

Comment on lines 106 to 136
// router.get(
// '/init',
// catchErrors(async (req, res, next) => {
// return res.render('initAccount',);
// }),
// );

// router.post(
// '/init',
// catchErrors(async (req, res, next) => {
// const { error, value } = jf.validateAsClass(req.query, controller.ResetCredentials);

// if (error) {
// throw new HttpException(400, { message: `Invalid request: ${error.message}` });
// }

// // I have no idea why joiful throws a fit here but this is the necessary workaround
// const verifyEmail = await controller.verifyEmail(
// value as unknown as controller.ResetCredentials,
// );

// return res.render('initAccountSuccess', {
// id: value.id,
// key: value.key,
// email: verifyEmail.email,
// });
// }),
// );



Copy link
Member

Choose a reason for hiding this comment

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

Not sure why the commented block here but of course let me know if you need any help w/this

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.

Rework account creation flow
3 participants