Skip to content

Commit

Permalink
Type Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Oct 8, 2020
1 parent 45a1028 commit 0765496
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 97 deletions.
4 changes: 2 additions & 2 deletions examples-next/basic/keystone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ const auth = createAuth({
},
},
passwordResetLink: {
sendToken: function (args): void {
sendToken(args) {
console.log(`Password reset info:`, args);
},
},
magicAuthLink: {
sendToken: function (args): void {
sendToken(args) {
console.log(`Magic auth info:`, args);
},
},
Expand Down
1 change: 1 addition & 0 deletions packages-next/auth/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

# Backlog

- [ ] Handle session token authorisation header use case
- [ ] Review the API that session functions get, try not to provide the keystone instance
- [ ] 2FA
- [ ] Social Auth
4 changes: 1 addition & 3 deletions packages-next/auth/src/gql/getBaseAuthSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export function getBaseAuthSchema({
AUTH_TOKEN_REDEMPTION_TOKEN_MISMATCH
AUTH_TOKEN_REDEMPTION_TOKEN_EXPIRED
AUTH_TOKEN_REDEMPTION_TOKEN_REDEEMED
INTERNAL_ERROR
CUSTOM_ERROR
}
# Password auth
Expand All @@ -50,7 +48,7 @@ export function getBaseAuthSchema({
}
union ${gqlNames.ItemAuthenticationWithPasswordResult} = ${gqlNames.ItemAuthenticationWithPasswordSuccess} | ${gqlNames.ItemAuthenticationWithPasswordFailure}
type ${gqlNames.ItemAuthenticationWithPasswordSuccess} {
token: String!
sessionToken: String!
item: ${listKey}!
}
type ${gqlNames.ItemAuthenticationWithPasswordFailure} {
Expand Down
12 changes: 6 additions & 6 deletions packages-next/auth/src/gql/getMagicAuthLinkSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function getMagicAuthLinkSchema({
secretField: string;
protectIdentities: boolean;
gqlNames: AuthGqlNames;
magicAuthLink?: AuthTokenTypeConfig;
magicAuthLink: AuthTokenTypeConfig;
}) {
return graphQLSchemaExtension({
typeDefs: `
Expand All @@ -27,11 +27,11 @@ export function getMagicAuthLinkSchema({
${gqlNames.sendItemMagicAuthLink}(${identityField}: String!): ${gqlNames.SendItemMagicAuthLinkResult}!
}
type ${gqlNames.SendItemMagicAuthLinkResult} {
code: AuthErrorCode
message: String
code: AuthErrorCode!
message: String!
}
type Mutation {
${gqlNames.redeemItemMagicAuthToken}(${identityField}: String!, token: String!): ${gqlNames.RedeemItemMagicAuthTokenResult}!
${gqlNames.redeemItemMagicAuthToken}(${identityField}: String!, token: String!): ${gqlNames.RedeemItemMagicAuthTokenResult}
}
union ${gqlNames.RedeemItemMagicAuthTokenResult} = ${gqlNames.RedeemItemMagicAuthTokenSuccess} | ${gqlNames.RedeemItemMagicAuthTokenFailure}
type ${gqlNames.RedeemItemMagicAuthTokenSuccess} {
Expand Down Expand Up @@ -69,7 +69,7 @@ export function getMagicAuthLinkSchema({
return { code: result.code, message };
}
if (result.success) {
await magicAuthLink?.sendToken({
await magicAuthLink.sendToken({
itemId: result.itemId,
identity,
token: result.token,
Expand All @@ -84,7 +84,7 @@ export function getMagicAuthLinkSchema({
list,
identityField,
protectIdentities,
magicAuthLink?.tokensValidForMins,
magicAuthLink.tokensValidForMins,
args,
ctx
);
Expand Down
8 changes: 4 additions & 4 deletions packages-next/auth/src/gql/getPasswordResetSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getPasswordResetSchema({
secretField: string;
protectIdentities: boolean;
gqlNames: AuthGqlNames;
passwordResetLink?: AuthTokenTypeConfig;
passwordResetLink: AuthTokenTypeConfig;
}) {
return graphQLSchemaExtension({
typeDefs: `
Expand Down Expand Up @@ -73,7 +73,7 @@ export function getPasswordResetSchema({
return { code: result.code, message };
}
if (result.success) {
await passwordResetLink?.sendToken({
await passwordResetLink.sendToken({
itemId: result.itemId,
identity,
token: result.token,
Expand All @@ -88,7 +88,7 @@ export function getPasswordResetSchema({
list,
identityField,
protectIdentities,
passwordResetLink?.tokensValidForMins,
passwordResetLink.tokensValidForMins,
args,
ctx
);
Expand Down Expand Up @@ -133,7 +133,7 @@ export function getPasswordResetSchema({
list,
identityField,
protectIdentities,
passwordResetLink?.tokensValidForMins,
passwordResetLink.tokensValidForMins,
args
);

Expand Down
Loading

0 comments on commit 0765496

Please sign in to comment.