Skip to content

Commit

Permalink
Rename updateAuthToken to createAuthToken (#5009)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Mar 4, 2021
1 parent ef63dcd commit 2bf7101
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-hornets-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/auth': patch
---

Renamed internal function `updateAuthToken` to `createAuthToken`.
4 changes: 2 additions & 2 deletions packages-next/auth/src/gql/getMagicAuthLinkSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { GraphQLSchemaExtension } from '@keystone-next/types';

import { AuthGqlNames, AuthTokenTypeConfig } from '../types';

import { updateAuthToken } from '../lib/updateAuthToken';
import { createAuthToken } from '../lib/createAuthToken';
import { validateAuthToken } from '../lib/validateAuthToken';
import { getAuthTokenErrorMessage } from '../lib/getErrorMessage';

Expand Down Expand Up @@ -63,7 +63,7 @@ export function getMagicAuthLinkSchema<I extends string>({
const tokenType = 'magicAuth';
const identity = args[identityField];

const result = await updateAuthToken(identityField, protectIdentities, identity, itemAPI);
const result = await createAuthToken(identityField, protectIdentities, identity, itemAPI);

// Note: `success` can be false with no code
if (!result.success && result.code) {
Expand Down
4 changes: 2 additions & 2 deletions packages-next/auth/src/gql/getPasswordResetSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { GraphQLSchemaExtension } from '@keystone-next/types';

import { AuthGqlNames, AuthTokenTypeConfig } from '../types';

import { updateAuthToken } from '../lib/updateAuthToken';
import { createAuthToken } from '../lib/createAuthToken';
import { validateAuthToken } from '../lib/validateAuthToken';
import { getAuthTokenErrorMessage } from '../lib/getErrorMessage';

Expand Down Expand Up @@ -66,7 +66,7 @@ export function getPasswordResetSchema<I extends string, S extends string>({
const itemAPI = context.sudo().lists[listKey];
const tokenType = 'passwordReset';
const identity = args[identityField];
const result = await updateAuthToken(identityField, protectIdentities, identity, itemAPI);
const result = await createAuthToken(identityField, protectIdentities, identity, itemAPI);

// Note: `success` can be false with no code
if (!result.success && result.code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function generateToken(length: number): string {

// TODO: Auth token mutations may leak user identities due to timing attacks :(
// We don't (currently) make any effort to mitigate the time taken to record the new token or sent the email when successful
export async function updateAuthToken(
export async function createAuthToken(
identityField: string,
protectIdentities: boolean,
identity: string,
Expand Down

1 comment on commit 2bf7101

@vercel
Copy link

@vercel vercel bot commented on 2bf7101 Mar 4, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.