Skip to content

Commit 39c72bd

Browse files
committed
require a preptoken in Signup
found while writing upcoming tests
1 parent bf1707e commit 39c72bd

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

api.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ func xcanonicalAddress(email string) string {
181181
// Signup registers a new account. We send an email for users to verify they
182182
// control the email address. If we already have a verified account, we send a
183183
// password reset instead.
184-
func (API) Signup(ctx context.Context, email string) {
184+
func (API) Signup(ctx context.Context, prepToken string, email string) {
185185
reqInfo := ctx.Value(requestInfoCtxKey).(requestInfo)
186186

187187
xrate(ratelimitSignup, reqInfo.Request)
188+
xcheckprep(reqInfo, prepToken)
188189

189190
email = xcanonicalAddress(email)
190191
emailAddr, err := smtp.ParseAddress(email)

api.json

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
"Name": "Signup",
77
"Docs": "Signup registers a new account. We send an email for users to verify they\ncontrol the email address. If we already have a verified account, we send a\npassword reset instead.",
88
"Params": [
9+
{
10+
"Name": "prepToken",
11+
"Typewords": [
12+
"string"
13+
]
14+
},
915
{
1016
"Name": "email",
1117
"Typewords": [

api.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ export class Client {
216216
// Signup registers a new account. We send an email for users to verify they
217217
// control the email address. If we already have a verified account, we send a
218218
// password reset instead.
219-
async Signup(email: string): Promise<void> {
219+
async Signup(prepToken: string, email: string): Promise<void> {
220220
const fn: string = "Signup"
221-
const paramTypes: string[][] = [["string"]]
221+
const paramTypes: string[][] = [["string"],["string"]]
222222
const returnTypes: string[][] = []
223-
const params: any[] = [email]
223+
const params: any[] = [prepToken, email]
224224
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params) as void
225225
}
226226

index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ var api;
6969
// Signup registers a new account. We send an email for users to verify they
7070
// control the email address. If we already have a verified account, we send a
7171
// password reset instead.
72-
async Signup(email) {
72+
async Signup(prepToken, email) {
7373
const fn = "Signup";
74-
const paramTypes = [["string"]];
74+
const paramTypes = [["string"], ["string"]];
7575
const returnTypes = [];
76-
const params = [email];
76+
const params = [prepToken, email];
7777
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params);
7878
}
7979
// SignupEmail returns the email address for a verify token. So we can show it, and
@@ -1291,7 +1291,8 @@ const signup = (home) => {
12911291
e.stopPropagation();
12921292
e.preventDefault();
12931293
await check(fieldset, async () => {
1294-
await client.Signup(email.value.trim());
1294+
const prepToken = await client.Prep();
1295+
await client.Signup(prepToken, email.value.trim());
12951296
signedup(email.value.trim());
12961297
});
12971298
}, fieldset = dom.fieldset(dom.label(style({ display: 'inline' }), 'Email address', ' ', email = dom.input(attr.type('email'), attr.required(''))), ' ', dom.submitbutton('Create account')), dom.p("We'll send you an email with a confirmation link."))),

index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,8 @@ const signup = (home: api.Home) => {
864864
e.preventDefault()
865865

866866
await check(fieldset, async () => {
867-
await client.Signup(email!.value.trim())
867+
const prepToken = await client.Prep()
868+
await client.Signup(prepToken, email!.value.trim())
868869
signedup(email!.value.trim())
869870
})
870871
},

0 commit comments

Comments
 (0)