feat: disableLocalStrategy with auth fields still enabled (#9579)
Adds configuration options to `auth.disableLocalStrategy` to allow customization of how payload treats an auth enabled collection. Two new properties have been added to `disableLocalStrategy`: - `enableFields` Include auth fields on the collection even though the local strategy is disabled. Useful when you do not want the database or types to vary depending on the auth configuration used. - `optionalPassword`: makes the password field not required
This commit is contained in:
@@ -126,12 +126,20 @@ export function initCollections({ config, graphqlResult }: InitCollectionsGraphQ
|
|||||||
|
|
||||||
const mutationInputFields = [...fields]
|
const mutationInputFields = [...fields]
|
||||||
|
|
||||||
if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {
|
if (
|
||||||
|
collectionConfig.auth &&
|
||||||
|
(!collectionConfig.auth.disableLocalStrategy ||
|
||||||
|
(typeof collectionConfig.auth.disableLocalStrategy === 'object' &&
|
||||||
|
collectionConfig.auth.disableLocalStrategy.optionalPassword))
|
||||||
|
) {
|
||||||
mutationInputFields.push({
|
mutationInputFields.push({
|
||||||
name: 'password',
|
name: 'password',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
label: 'Password',
|
label: 'Password',
|
||||||
required: true,
|
required: !(
|
||||||
|
typeof collectionConfig.auth.disableLocalStrategy === 'object' &&
|
||||||
|
collectionConfig.auth.disableLocalStrategy.optionalPassword
|
||||||
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ export const getBaseAuthFields = (authConfig: IncomingAuthType): Field[] => {
|
|||||||
authFields.push(...apiKeyFields)
|
authFields.push(...apiKeyFields)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!authConfig.disableLocalStrategy) {
|
if (
|
||||||
|
!authConfig.disableLocalStrategy ||
|
||||||
|
(typeof authConfig.disableLocalStrategy === 'object' &&
|
||||||
|
authConfig.disableLocalStrategy.enableFields)
|
||||||
|
) {
|
||||||
const emailField = { ...emailFieldConfig }
|
const emailField = { ...emailFieldConfig }
|
||||||
let usernameField: TextField | undefined
|
let usernameField: TextField | undefined
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import type { PayloadRequest, Where } from '../../types/index.js'
|
|||||||
|
|
||||||
import { buildAfterOperation } from '../../collections/operations/utils.js'
|
import { buildAfterOperation } from '../../collections/operations/utils.js'
|
||||||
import { APIError } from '../../errors/index.js'
|
import { APIError } from '../../errors/index.js'
|
||||||
|
import { Forbidden } from '../../index.js'
|
||||||
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
||||||
import { initTransaction } from '../../utilities/initTransaction.js'
|
import { initTransaction } from '../../utilities/initTransaction.js'
|
||||||
import { killTransaction } from '../../utilities/killTransaction.js'
|
import { killTransaction } from '../../utilities/killTransaction.js'
|
||||||
@@ -43,6 +44,11 @@ export const forgotPasswordOperation = async <TSlug extends CollectionSlug>(
|
|||||||
? data.username.toLowerCase().trim()
|
? data.username.toLowerCase().trim()
|
||||||
: null
|
: null
|
||||||
|
|
||||||
|
let args = incomingArgs
|
||||||
|
|
||||||
|
if (incomingArgs.collection.config.auth.disableLocalStrategy) {
|
||||||
|
throw new Forbidden(incomingArgs.req.t)
|
||||||
|
}
|
||||||
if (!sanitizedEmail && !sanitizedUsername) {
|
if (!sanitizedEmail && !sanitizedUsername) {
|
||||||
throw new APIError(
|
throw new APIError(
|
||||||
`Missing ${loginWithUsername ? 'username' : 'email'}.`,
|
`Missing ${loginWithUsername ? 'username' : 'email'}.`,
|
||||||
@@ -50,8 +56,6 @@ export const forgotPasswordOperation = async <TSlug extends CollectionSlug>(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = incomingArgs
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const shouldCommit = await initTransaction(args.req)
|
const shouldCommit = await initTransaction(args.req)
|
||||||
|
|
||||||
@@ -74,7 +78,6 @@ export const forgotPasswordOperation = async <TSlug extends CollectionSlug>(
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
collection: { config: collectionConfig },
|
collection: { config: collectionConfig },
|
||||||
data,
|
|
||||||
disableEmail,
|
disableEmail,
|
||||||
expiration,
|
expiration,
|
||||||
req: {
|
req: {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type { User } from '../types.js'
|
|||||||
import { buildAfterOperation } from '../../collections/operations/utils.js'
|
import { buildAfterOperation } from '../../collections/operations/utils.js'
|
||||||
import { AuthenticationError, LockedAuth, ValidationError } from '../../errors/index.js'
|
import { AuthenticationError, LockedAuth, ValidationError } from '../../errors/index.js'
|
||||||
import { afterRead } from '../../fields/hooks/afterRead/index.js'
|
import { afterRead } from '../../fields/hooks/afterRead/index.js'
|
||||||
|
import { Forbidden } from '../../index.js'
|
||||||
import { killTransaction } from '../../utilities/killTransaction.js'
|
import { killTransaction } from '../../utilities/killTransaction.js'
|
||||||
import sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'
|
import sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'
|
||||||
import { getFieldsToSign } from '../getFieldsToSign.js'
|
import { getFieldsToSign } from '../getFieldsToSign.js'
|
||||||
@@ -40,6 +41,10 @@ export const loginOperation = async <TSlug extends CollectionSlug>(
|
|||||||
): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> => {
|
): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> => {
|
||||||
let args = incomingArgs
|
let args = incomingArgs
|
||||||
|
|
||||||
|
if (args.collection.config.auth.disableLocalStrategy) {
|
||||||
|
throw new Forbidden(args.req.t)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// /////////////////////////////////////
|
// /////////////////////////////////////
|
||||||
// beforeOperation - Collection
|
// beforeOperation - Collection
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ export const registerFirstUserOperation = async <TSlug extends CollectionSlug>(
|
|||||||
req: { payload },
|
req: { payload },
|
||||||
} = args
|
} = args
|
||||||
|
|
||||||
|
if (config.auth.disableLocalStrategy) {
|
||||||
|
throw new Forbidden(req.t)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const shouldCommit = await initTransaction(req)
|
const shouldCommit = await initTransaction(req)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import httpStatus from 'http-status'
|
|||||||
import type { Collection } from '../../collections/config/types.js'
|
import type { Collection } from '../../collections/config/types.js'
|
||||||
import type { PayloadRequest } from '../../types/index.js'
|
import type { PayloadRequest } from '../../types/index.js'
|
||||||
|
|
||||||
import { APIError } from '../../errors/index.js'
|
import { APIError, Forbidden } from '../../errors/index.js'
|
||||||
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
||||||
import { initTransaction } from '../../utilities/initTransaction.js'
|
import { initTransaction } from '../../utilities/initTransaction.js'
|
||||||
import { killTransaction } from '../../utilities/killTransaction.js'
|
import { killTransaction } from '../../utilities/killTransaction.js'
|
||||||
@@ -29,13 +29,6 @@ export type Arguments = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const resetPasswordOperation = async (args: Arguments): Promise<Result> => {
|
export const resetPasswordOperation = async (args: Arguments): Promise<Result> => {
|
||||||
if (
|
|
||||||
!Object.prototype.hasOwnProperty.call(args.data, 'token') ||
|
|
||||||
!Object.prototype.hasOwnProperty.call(args.data, 'password')
|
|
||||||
) {
|
|
||||||
throw new APIError('Missing required data.', httpStatus.BAD_REQUEST)
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
collection: { config: collectionConfig },
|
collection: { config: collectionConfig },
|
||||||
data,
|
data,
|
||||||
@@ -48,6 +41,17 @@ export const resetPasswordOperation = async (args: Arguments): Promise<Result> =
|
|||||||
req,
|
req,
|
||||||
} = args
|
} = args
|
||||||
|
|
||||||
|
if (
|
||||||
|
!Object.prototype.hasOwnProperty.call(data, 'token') ||
|
||||||
|
!Object.prototype.hasOwnProperty.call(data, 'password')
|
||||||
|
) {
|
||||||
|
throw new APIError('Missing required data.', httpStatus.BAD_REQUEST)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectionConfig.auth.disableLocalStrategy) {
|
||||||
|
throw new Forbidden(req.t)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const shouldCommit = await initTransaction(req)
|
const shouldCommit = await initTransaction(req)
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type { CollectionSlug } from '../../index.js'
|
|||||||
import type { PayloadRequest, Where } from '../../types/index.js'
|
import type { PayloadRequest, Where } from '../../types/index.js'
|
||||||
|
|
||||||
import { APIError } from '../../errors/index.js'
|
import { APIError } from '../../errors/index.js'
|
||||||
|
import { Forbidden } from '../../index.js'
|
||||||
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
||||||
import { initTransaction } from '../../utilities/initTransaction.js'
|
import { initTransaction } from '../../utilities/initTransaction.js'
|
||||||
import { killTransaction } from '../../utilities/killTransaction.js'
|
import { killTransaction } from '../../utilities/killTransaction.js'
|
||||||
@@ -44,6 +45,9 @@ export const unlockOperation = async <TSlug extends CollectionSlug>(
|
|||||||
args.data.username.toLowerCase().trim()) ||
|
args.data.username.toLowerCase().trim()) ||
|
||||||
null
|
null
|
||||||
|
|
||||||
|
if (collectionConfig.auth.disableLocalStrategy) {
|
||||||
|
throw new Forbidden(req.t)
|
||||||
|
}
|
||||||
if (!sanitizedEmail && !sanitizedUsername) {
|
if (!sanitizedEmail && !sanitizedUsername) {
|
||||||
throw new APIError(
|
throw new APIError(
|
||||||
`Missing ${collectionConfig.auth.loginWithUsername ? 'username' : 'email'}.`,
|
`Missing ${collectionConfig.auth.loginWithUsername ? 'username' : 'email'}.`,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import httpStatus from 'http-status'
|
|||||||
import type { Collection } from '../../collections/config/types.js'
|
import type { Collection } from '../../collections/config/types.js'
|
||||||
import type { PayloadRequest } from '../../types/index.js'
|
import type { PayloadRequest } from '../../types/index.js'
|
||||||
|
|
||||||
import { APIError } from '../../errors/index.js'
|
import { APIError, Forbidden } from '../../errors/index.js'
|
||||||
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
import { commitTransaction } from '../../utilities/commitTransaction.js'
|
||||||
import { initTransaction } from '../../utilities/initTransaction.js'
|
import { initTransaction } from '../../utilities/initTransaction.js'
|
||||||
import { killTransaction } from '../../utilities/killTransaction.js'
|
import { killTransaction } from '../../utilities/killTransaction.js'
|
||||||
@@ -16,6 +16,10 @@ export type Args = {
|
|||||||
|
|
||||||
export const verifyEmailOperation = async (args: Args): Promise<boolean> => {
|
export const verifyEmailOperation = async (args: Args): Promise<boolean> => {
|
||||||
const { collection, req, token } = args
|
const { collection, req, token } = args
|
||||||
|
|
||||||
|
if (collection.config.auth.disableLocalStrategy) {
|
||||||
|
throw new Forbidden(req.t)
|
||||||
|
}
|
||||||
if (!Object.prototype.hasOwnProperty.call(args, 'token')) {
|
if (!Object.prototype.hasOwnProperty.call(args, 'token')) {
|
||||||
throw new APIError('Missing required data.', httpStatus.BAD_REQUEST)
|
throw new APIError('Missing required data.', httpStatus.BAD_REQUEST)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,16 @@ export interface IncomingAuthType {
|
|||||||
/**
|
/**
|
||||||
* Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own.
|
* Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own.
|
||||||
*/
|
*/
|
||||||
disableLocalStrategy?: true
|
disableLocalStrategy?:
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* Include auth fields on the collection even though the local strategy is disabled.
|
||||||
|
* Useful when you do not want the database or types to vary depending on the auth configuration.
|
||||||
|
*/
|
||||||
|
enableFields?: true
|
||||||
|
optionalPassword?: true
|
||||||
|
}
|
||||||
|
| true
|
||||||
/**
|
/**
|
||||||
* Customize the way that the forgotPassword operation functions.
|
* Customize the way that the forgotPassword operation functions.
|
||||||
* @link https://payloadcms.com/docs/authentication/email#forgot-password
|
* @link https://payloadcms.com/docs/authentication/email#forgot-password
|
||||||
|
|||||||
@@ -617,7 +617,13 @@ export function entityToJSONSchema(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('auth' in entity && entity.auth && !entity.auth?.disableLocalStrategy) {
|
if (
|
||||||
|
'auth' in entity &&
|
||||||
|
entity.auth &&
|
||||||
|
(!entity.auth?.disableLocalStrategy ||
|
||||||
|
(typeof entity.auth?.disableLocalStrategy === 'object' &&
|
||||||
|
entity.auth.disableLocalStrategy.enableFields))
|
||||||
|
) {
|
||||||
entity.flattenedFields.push({
|
entity.flattenedFields.push({
|
||||||
name: 'password',
|
name: 'password',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { SanitizedCollectionConfig } from 'payload'
|
|||||||
export type Props = {
|
export type Props = {
|
||||||
className?: string
|
className?: string
|
||||||
collectionSlug: SanitizedCollectionConfig['slug']
|
collectionSlug: SanitizedCollectionConfig['slug']
|
||||||
disableLocalStrategy?: boolean
|
disableLocalStrategy?: SanitizedCollectionConfig['auth']['disableLocalStrategy']
|
||||||
email: string
|
email: string
|
||||||
loginWithUsername: SanitizedCollectionConfig['auth']['loginWithUsername']
|
loginWithUsername: SanitizedCollectionConfig['auth']['loginWithUsername']
|
||||||
operation: 'create' | 'update'
|
operation: 'create' | 'update'
|
||||||
|
|||||||
@@ -6,7 +6,13 @@ import { v4 as uuid } from 'uuid'
|
|||||||
|
|
||||||
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
||||||
import { devUser } from '../credentials.js'
|
import { devUser } from '../credentials.js'
|
||||||
import { apiKeysSlug, namedSaveToJWTValue, saveToJWTKey, slug } from './shared.js'
|
import {
|
||||||
|
apiKeysSlug,
|
||||||
|
namedSaveToJWTValue,
|
||||||
|
partialDisableLocaleStrategiesSlug,
|
||||||
|
saveToJWTKey,
|
||||||
|
slug,
|
||||||
|
} from './shared.js'
|
||||||
|
|
||||||
export default buildConfigWithDefaults({
|
export default buildConfigWithDefaults({
|
||||||
admin: {
|
admin: {
|
||||||
@@ -174,6 +180,25 @@ export default buildConfigWithDefaults({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
slug: partialDisableLocaleStrategiesSlug,
|
||||||
|
auth: {
|
||||||
|
disableLocalStrategy: {
|
||||||
|
// optionalPassword: true,
|
||||||
|
enableFields: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fields: [
|
||||||
|
// with `enableFields: true`, the following DB columns will be created:
|
||||||
|
// email
|
||||||
|
// reset_password_token
|
||||||
|
// reset_password_expiration
|
||||||
|
// salt
|
||||||
|
// hash
|
||||||
|
// login_attempts
|
||||||
|
// lock_until
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
slug: apiKeysSlug,
|
slug: apiKeysSlug,
|
||||||
access: {
|
access: {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type { SanitizedConfig } from 'payload'
|
|||||||
import { expect, test } from '@playwright/test'
|
import { expect, test } from '@playwright/test'
|
||||||
import { devUser } from 'credentials.js'
|
import { devUser } from 'credentials.js'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { wait } from 'payload/shared'
|
|
||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'url'
|
||||||
import { v4 as uuid } from 'uuid'
|
import { v4 as uuid } from 'uuid'
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { Payload, User } from 'payload'
|
import type { FieldAffectingData, Payload, User } from 'payload'
|
||||||
|
|
||||||
import { jwtDecode } from 'jwt-decode'
|
import { jwtDecode } from 'jwt-decode'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
@@ -9,7 +9,13 @@ import type { NextRESTClient } from '../helpers/NextRESTClient.js'
|
|||||||
|
|
||||||
import { devUser } from '../credentials.js'
|
import { devUser } from '../credentials.js'
|
||||||
import { initPayloadInt } from '../helpers/initPayloadInt.js'
|
import { initPayloadInt } from '../helpers/initPayloadInt.js'
|
||||||
import { apiKeysSlug, namedSaveToJWTValue, saveToJWTKey, slug } from './shared.js'
|
import {
|
||||||
|
apiKeysSlug,
|
||||||
|
namedSaveToJWTValue,
|
||||||
|
partialDisableLocaleStrategiesSlug,
|
||||||
|
saveToJWTKey,
|
||||||
|
slug,
|
||||||
|
} from './shared.js'
|
||||||
|
|
||||||
let restClient: NextRESTClient
|
let restClient: NextRESTClient
|
||||||
let payload: Payload
|
let payload: Payload
|
||||||
@@ -709,6 +715,70 @@ describe('Auth', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('disableLocalStrategy', () => {
|
||||||
|
it('should allow create of a user with disableLocalStrategy', async () => {
|
||||||
|
const email = 'test@example.com'
|
||||||
|
const user = await payload.create({
|
||||||
|
collection: partialDisableLocaleStrategiesSlug,
|
||||||
|
data: {
|
||||||
|
email,
|
||||||
|
// password is not required
|
||||||
|
},
|
||||||
|
})
|
||||||
|
expect(user.email).toStrictEqual(email)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should retain fields when auth.disableLocalStrategy.enableFields is true', () => {
|
||||||
|
const authFields = payload.collections[partialDisableLocaleStrategiesSlug].config.fields
|
||||||
|
// eslint-disable-next-line jest/no-conditional-in-test
|
||||||
|
.filter((field) => 'name' in field && field.name)
|
||||||
|
.map((field) => (field as FieldAffectingData).name)
|
||||||
|
|
||||||
|
expect(authFields).toMatchObject([
|
||||||
|
'updatedAt',
|
||||||
|
'createdAt',
|
||||||
|
'email',
|
||||||
|
'resetPasswordToken',
|
||||||
|
'resetPasswordExpiration',
|
||||||
|
'salt',
|
||||||
|
'hash',
|
||||||
|
'loginAttempts',
|
||||||
|
'lockUntil',
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should prevent login of user with disableLocalStrategy.', async () => {
|
||||||
|
await payload.create({
|
||||||
|
collection: partialDisableLocaleStrategiesSlug,
|
||||||
|
data: {
|
||||||
|
email: devUser.email,
|
||||||
|
password: devUser.password,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
await expect(async () => {
|
||||||
|
await payload.login({
|
||||||
|
collection: partialDisableLocaleStrategiesSlug,
|
||||||
|
data: {
|
||||||
|
email: devUser.email,
|
||||||
|
password: devUser.password,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}).rejects.toThrow('You are not allowed to perform this action.')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('rest - should prevent login', async () => {
|
||||||
|
const response = await restClient.POST(`/${partialDisableLocaleStrategiesSlug}/login`, {
|
||||||
|
body: JSON.stringify({
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(response.status).toBe(403)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('API Key', () => {
|
describe('API Key', () => {
|
||||||
it('should authenticate via the correct API key user', async () => {
|
it('should authenticate via the correct API key user', async () => {
|
||||||
const usersQuery = await payload.find({
|
const usersQuery = await payload.find({
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
export interface Config {
|
export interface Config {
|
||||||
auth: {
|
auth: {
|
||||||
users: UserAuthOperations;
|
users: UserAuthOperations;
|
||||||
|
'partial-disable-locale-strategies': PartialDisableLocaleStrategyAuthOperations;
|
||||||
'api-keys': ApiKeyAuthOperations;
|
'api-keys': ApiKeyAuthOperations;
|
||||||
'public-users': PublicUserAuthOperations;
|
'public-users': PublicUserAuthOperations;
|
||||||
};
|
};
|
||||||
collections: {
|
collections: {
|
||||||
users: User;
|
users: User;
|
||||||
|
'partial-disable-locale-strategies': PartialDisableLocaleStrategy;
|
||||||
'api-keys': ApiKey;
|
'api-keys': ApiKey;
|
||||||
'public-users': PublicUser;
|
'public-users': PublicUser;
|
||||||
relationsCollection: RelationsCollection;
|
relationsCollection: RelationsCollection;
|
||||||
@@ -24,6 +26,7 @@ export interface Config {
|
|||||||
collectionsJoins: {};
|
collectionsJoins: {};
|
||||||
collectionsSelect: {
|
collectionsSelect: {
|
||||||
users: UsersSelect<false> | UsersSelect<true>;
|
users: UsersSelect<false> | UsersSelect<true>;
|
||||||
|
'partial-disable-locale-strategies': PartialDisableLocaleStrategiesSelect<false> | PartialDisableLocaleStrategiesSelect<true>;
|
||||||
'api-keys': ApiKeysSelect<false> | ApiKeysSelect<true>;
|
'api-keys': ApiKeysSelect<false> | ApiKeysSelect<true>;
|
||||||
'public-users': PublicUsersSelect<false> | PublicUsersSelect<true>;
|
'public-users': PublicUsersSelect<false> | PublicUsersSelect<true>;
|
||||||
relationsCollection: RelationsCollectionSelect<false> | RelationsCollectionSelect<true>;
|
relationsCollection: RelationsCollectionSelect<false> | RelationsCollectionSelect<true>;
|
||||||
@@ -32,7 +35,7 @@ export interface Config {
|
|||||||
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
|
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
|
||||||
};
|
};
|
||||||
db: {
|
db: {
|
||||||
defaultIDType: string;
|
defaultIDType: number;
|
||||||
};
|
};
|
||||||
globals: {};
|
globals: {};
|
||||||
globalsSelect: {};
|
globalsSelect: {};
|
||||||
@@ -41,6 +44,9 @@ export interface Config {
|
|||||||
| (User & {
|
| (User & {
|
||||||
collection: 'users';
|
collection: 'users';
|
||||||
})
|
})
|
||||||
|
| (PartialDisableLocaleStrategy & {
|
||||||
|
collection: 'partial-disable-locale-strategies';
|
||||||
|
})
|
||||||
| (ApiKey & {
|
| (ApiKey & {
|
||||||
collection: 'api-keys';
|
collection: 'api-keys';
|
||||||
})
|
})
|
||||||
@@ -70,6 +76,24 @@ export interface UserAuthOperations {
|
|||||||
password: string;
|
password: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
export interface PartialDisableLocaleStrategyAuthOperations {
|
||||||
|
forgotPassword: {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
login: {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
registerFirstUser: {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
unlock: {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
export interface ApiKeyAuthOperations {
|
export interface ApiKeyAuthOperations {
|
||||||
forgotPassword: {
|
forgotPassword: {
|
||||||
email: string;
|
email: string;
|
||||||
@@ -111,7 +135,7 @@ export interface PublicUserAuthOperations {
|
|||||||
* via the `definition` "users".
|
* via the `definition` "users".
|
||||||
*/
|
*/
|
||||||
export interface User {
|
export interface User {
|
||||||
id: string;
|
id: number;
|
||||||
adminOnlyField?: string | null;
|
adminOnlyField?: string | null;
|
||||||
roles: ('admin' | 'editor' | 'moderator' | 'user' | 'viewer')[];
|
roles: ('admin' | 'editor' | 'moderator' | 'user' | 'viewer')[];
|
||||||
namedSaveToJWT?: string | null;
|
namedSaveToJWT?: string | null;
|
||||||
@@ -146,12 +170,29 @@ export interface User {
|
|||||||
lockUntil?: string | null;
|
lockUntil?: string | null;
|
||||||
password?: string | null;
|
password?: string | null;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "partial-disable-locale-strategies".
|
||||||
|
*/
|
||||||
|
export interface PartialDisableLocaleStrategy {
|
||||||
|
id: number;
|
||||||
|
updatedAt: string;
|
||||||
|
createdAt: string;
|
||||||
|
email: string;
|
||||||
|
resetPasswordToken?: string | null;
|
||||||
|
resetPasswordExpiration?: string | null;
|
||||||
|
salt?: string | null;
|
||||||
|
hash?: string | null;
|
||||||
|
loginAttempts?: number | null;
|
||||||
|
lockUntil?: string | null;
|
||||||
|
password?: string | null;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "api-keys".
|
* via the `definition` "api-keys".
|
||||||
*/
|
*/
|
||||||
export interface ApiKey {
|
export interface ApiKey {
|
||||||
id: string;
|
id: number;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
enableAPIKey?: boolean | null;
|
enableAPIKey?: boolean | null;
|
||||||
@@ -163,7 +204,7 @@ export interface ApiKey {
|
|||||||
* via the `definition` "public-users".
|
* via the `definition` "public-users".
|
||||||
*/
|
*/
|
||||||
export interface PublicUser {
|
export interface PublicUser {
|
||||||
id: string;
|
id: number;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
email: string;
|
email: string;
|
||||||
@@ -182,8 +223,8 @@ export interface PublicUser {
|
|||||||
* via the `definition` "relationsCollection".
|
* via the `definition` "relationsCollection".
|
||||||
*/
|
*/
|
||||||
export interface RelationsCollection {
|
export interface RelationsCollection {
|
||||||
id: string;
|
id: number;
|
||||||
rel?: (string | null) | User;
|
rel?: (number | null) | User;
|
||||||
text?: string | null;
|
text?: string | null;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
@@ -193,37 +234,45 @@ export interface RelationsCollection {
|
|||||||
* via the `definition` "payload-locked-documents".
|
* via the `definition` "payload-locked-documents".
|
||||||
*/
|
*/
|
||||||
export interface PayloadLockedDocument {
|
export interface PayloadLockedDocument {
|
||||||
id: string;
|
id: number;
|
||||||
document?:
|
document?:
|
||||||
| ({
|
| ({
|
||||||
relationTo: 'users';
|
relationTo: 'users';
|
||||||
value: string | User;
|
value: number | User;
|
||||||
|
} | null)
|
||||||
|
| ({
|
||||||
|
relationTo: 'partial-disable-locale-strategies';
|
||||||
|
value: number | PartialDisableLocaleStrategy;
|
||||||
} | null)
|
} | null)
|
||||||
| ({
|
| ({
|
||||||
relationTo: 'api-keys';
|
relationTo: 'api-keys';
|
||||||
value: string | ApiKey;
|
value: number | ApiKey;
|
||||||
} | null)
|
} | null)
|
||||||
| ({
|
| ({
|
||||||
relationTo: 'public-users';
|
relationTo: 'public-users';
|
||||||
value: string | PublicUser;
|
value: number | PublicUser;
|
||||||
} | null)
|
} | null)
|
||||||
| ({
|
| ({
|
||||||
relationTo: 'relationsCollection';
|
relationTo: 'relationsCollection';
|
||||||
value: string | RelationsCollection;
|
value: number | RelationsCollection;
|
||||||
} | null);
|
} | null);
|
||||||
globalSlug?: string | null;
|
globalSlug?: string | null;
|
||||||
user:
|
user:
|
||||||
| {
|
| {
|
||||||
relationTo: 'users';
|
relationTo: 'users';
|
||||||
value: string | User;
|
value: number | User;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: 'partial-disable-locale-strategies';
|
||||||
|
value: number | PartialDisableLocaleStrategy;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
relationTo: 'api-keys';
|
relationTo: 'api-keys';
|
||||||
value: string | ApiKey;
|
value: number | ApiKey;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
relationTo: 'public-users';
|
relationTo: 'public-users';
|
||||||
value: string | PublicUser;
|
value: number | PublicUser;
|
||||||
};
|
};
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
@@ -233,19 +282,23 @@ export interface PayloadLockedDocument {
|
|||||||
* via the `definition` "payload-preferences".
|
* via the `definition` "payload-preferences".
|
||||||
*/
|
*/
|
||||||
export interface PayloadPreference {
|
export interface PayloadPreference {
|
||||||
id: string;
|
id: number;
|
||||||
user:
|
user:
|
||||||
| {
|
| {
|
||||||
relationTo: 'users';
|
relationTo: 'users';
|
||||||
value: string | User;
|
value: number | User;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: 'partial-disable-locale-strategies';
|
||||||
|
value: number | PartialDisableLocaleStrategy;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
relationTo: 'api-keys';
|
relationTo: 'api-keys';
|
||||||
value: string | ApiKey;
|
value: number | ApiKey;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
relationTo: 'public-users';
|
relationTo: 'public-users';
|
||||||
value: string | PublicUser;
|
value: number | PublicUser;
|
||||||
};
|
};
|
||||||
key?: string | null;
|
key?: string | null;
|
||||||
value?:
|
value?:
|
||||||
@@ -265,7 +318,7 @@ export interface PayloadPreference {
|
|||||||
* via the `definition` "payload-migrations".
|
* via the `definition` "payload-migrations".
|
||||||
*/
|
*/
|
||||||
export interface PayloadMigration {
|
export interface PayloadMigration {
|
||||||
id: string;
|
id: number;
|
||||||
name?: string | null;
|
name?: string | null;
|
||||||
batch?: number | null;
|
batch?: number | null;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
@@ -317,6 +370,21 @@ export interface UsersSelect<T extends boolean = true> {
|
|||||||
loginAttempts?: T;
|
loginAttempts?: T;
|
||||||
lockUntil?: T;
|
lockUntil?: T;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "partial-disable-locale-strategies_select".
|
||||||
|
*/
|
||||||
|
export interface PartialDisableLocaleStrategiesSelect<T extends boolean = true> {
|
||||||
|
updatedAt?: T;
|
||||||
|
createdAt?: T;
|
||||||
|
email?: T;
|
||||||
|
resetPasswordToken?: T;
|
||||||
|
resetPasswordExpiration?: T;
|
||||||
|
salt?: T;
|
||||||
|
hash?: T;
|
||||||
|
loginAttempts?: T;
|
||||||
|
lockUntil?: T;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "api-keys_select".
|
* via the `definition` "api-keys_select".
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
export const slug = 'users'
|
export const slug = 'users'
|
||||||
export const apiKeysSlug = 'api-keys'
|
export const apiKeysSlug = 'api-keys'
|
||||||
|
|
||||||
|
export const partialDisableLocaleStrategiesSlug = 'partial-disable-locale-strategies'
|
||||||
|
|
||||||
export const namedSaveToJWTValue = 'namedSaveToJWT value'
|
export const namedSaveToJWTValue = 'namedSaveToJWT value'
|
||||||
|
|
||||||
export const saveToJWTKey = 'x-custom-jwt-property-name'
|
export const saveToJWTKey = 'x-custom-jwt-property-name'
|
||||||
|
|||||||
Reference in New Issue
Block a user