Skip to content

Commit

Permalink
Merge pull request #576 from nhost/magic-link-register
Browse files Browse the repository at this point in the history
Use register instead of sign-up for Magic Link
  • Loading branch information
Johan Eliasson authored Jun 8, 2021
2 parents 2a8106b + ea7acd6 commit b79346c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/routes/auth/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ it('should create an account without a password when magic link login is enabled
await deleteMailHogEmail(message)

{
const { status } = await request.get(`/auth/magic-link?action=sign-up&token=${token}`)
const { status } = await request.get(`/auth/magic-link?action=register&token=${token}`)
expect(status).toBe(302)
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ it('should sign the user in without password when magic link is enabled', async
const token = await getHeaderFromLatestEmailAndDelete(email, 'X-Token')

{
const { status } = await request.get(`/auth/magic-link?action=sign-up&token=${token}`)
const { status } = await request.get(`/auth/magic-link?action=register&token=${token}`)
expect(status).toBe(302)
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/auth/magic-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function magicLink({ query }: Request, res: Response): Promise<unknown> {
const { token, action } = await magicLinkQuery.validateAsync(query);
const useCookie = typeof query.cookie !== 'undefined' ? query.cookie === 'true' : true
let refresh_token = token;
if (action === 'sign-up') {
if (action === 'register') {
const new_ticket = uuidv4()
let hasuraData: UpdateAccountData
try {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/auth/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ async function registerAccount(req: Request, res: Response): Promise<unknown> {
display_name,
token: ticket,
url: APPLICATION.SERVER_URL,
action: 'sign up',
action_url: 'sign-up'
action: 'register',
action_url: 'register'
}
})
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ export const fileMetadataUpdate = Joi.object({

export const magicLinkQuery = Joi.object({
token: Joi.string().required(),
action: Joi.string().valid('log-in', 'sign-up').required(),
action: Joi.string().valid('log-in', 'register').required(),
cookie: Joi.boolean().optional(),
});

0 comments on commit b79346c

Please sign in to comment.