Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
164 lines
4.6 KiB
Plaintext
164 lines
4.6 KiB
Plaintext
import { defaultAccess } from '../../auth/defaultAccess.js';
|
|
/**
|
|
* @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.
|
|
*/ export const defaults = {
|
|
access: {
|
|
create: defaultAccess,
|
|
delete: defaultAccess,
|
|
read: defaultAccess,
|
|
unlock: defaultAccess,
|
|
update: defaultAccess
|
|
},
|
|
admin: {
|
|
components: {},
|
|
custom: {},
|
|
enableRichTextLink: true,
|
|
enableRichTextRelationship: true,
|
|
pagination: {
|
|
defaultLimit: 10,
|
|
limits: [
|
|
5,
|
|
10,
|
|
25,
|
|
50,
|
|
100
|
|
]
|
|
},
|
|
useAsTitle: 'id'
|
|
},
|
|
auth: false,
|
|
custom: {},
|
|
endpoints: [],
|
|
fields: [],
|
|
hooks: {
|
|
afterChange: [],
|
|
afterDelete: [],
|
|
afterForgotPassword: [],
|
|
afterLogin: [],
|
|
afterLogout: [],
|
|
afterMe: [],
|
|
afterOperation: [],
|
|
afterRead: [],
|
|
afterRefresh: [],
|
|
beforeChange: [],
|
|
beforeDelete: [],
|
|
beforeLogin: [],
|
|
beforeOperation: [],
|
|
beforeRead: [],
|
|
beforeValidate: [],
|
|
me: [],
|
|
refresh: []
|
|
},
|
|
indexes: [],
|
|
timestamps: true,
|
|
upload: false,
|
|
versions: false
|
|
};
|
|
export const addDefaultsToCollectionConfig = (collection)=>{
|
|
collection.access = {
|
|
create: defaultAccess,
|
|
delete: defaultAccess,
|
|
read: defaultAccess,
|
|
unlock: defaultAccess,
|
|
update: defaultAccess,
|
|
...collection.access || {}
|
|
};
|
|
collection.admin = {
|
|
components: {},
|
|
custom: {},
|
|
enableRichTextLink: true,
|
|
enableRichTextRelationship: true,
|
|
useAsTitle: 'id',
|
|
...collection.admin || {},
|
|
pagination: {
|
|
defaultLimit: 10,
|
|
limits: [
|
|
5,
|
|
10,
|
|
25,
|
|
50,
|
|
100
|
|
],
|
|
...collection.admin?.pagination || {}
|
|
}
|
|
};
|
|
collection.auth = collection.auth ?? false;
|
|
collection.custom = collection.custom ?? {};
|
|
collection.endpoints = collection.endpoints ?? [];
|
|
collection.fields = collection.fields ?? [];
|
|
collection.folders = collection.folders ?? false;
|
|
collection.hooks = {
|
|
afterChange: [],
|
|
afterDelete: [],
|
|
afterForgotPassword: [],
|
|
afterLogin: [],
|
|
afterLogout: [],
|
|
afterMe: [],
|
|
afterOperation: [],
|
|
afterRead: [],
|
|
afterRefresh: [],
|
|
beforeChange: [],
|
|
beforeDelete: [],
|
|
beforeLogin: [],
|
|
beforeOperation: [],
|
|
beforeRead: [],
|
|
beforeValidate: [],
|
|
me: [],
|
|
refresh: [],
|
|
...collection.hooks || {}
|
|
};
|
|
collection.timestamps = collection.timestamps ?? true;
|
|
collection.upload = collection.upload ?? false;
|
|
collection.versions = collection.versions ?? false;
|
|
collection.indexes = collection.indexes ?? [];
|
|
return collection;
|
|
};
|
|
/**
|
|
* @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.
|
|
*/ export const authDefaults = {
|
|
cookies: {
|
|
sameSite: 'Lax',
|
|
secure: false
|
|
},
|
|
forgotPassword: {},
|
|
lockTime: 600000,
|
|
loginWithUsername: false,
|
|
maxLoginAttempts: 5,
|
|
tokenExpiration: 7200,
|
|
useSessions: true,
|
|
verify: false
|
|
};
|
|
export const addDefaultsToAuthConfig = (auth)=>{
|
|
auth.cookies = {
|
|
sameSite: 'Lax',
|
|
secure: false,
|
|
...auth.cookies || {}
|
|
};
|
|
auth.forgotPassword = auth.forgotPassword ?? {};
|
|
auth.lockTime = auth.lockTime ?? 600000; // 10 minutes
|
|
auth.loginWithUsername = auth.loginWithUsername ?? false;
|
|
auth.maxLoginAttempts = auth.maxLoginAttempts ?? 5;
|
|
auth.tokenExpiration = auth.tokenExpiration ?? 7200;
|
|
auth.useSessions = auth.useSessions ?? true;
|
|
auth.verify = auth.verify ?? false;
|
|
auth.strategies = auth.strategies ?? [];
|
|
if (!auth.disableLocalStrategy && auth.verify === true) {
|
|
auth.verify = {};
|
|
}
|
|
return auth;
|
|
};
|
|
/**
|
|
* @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.
|
|
*/ export const loginWithUsernameDefaults = {
|
|
allowEmailLogin: false,
|
|
requireEmail: false,
|
|
requireUsername: true
|
|
};
|
|
export const addDefaultsToLoginWithUsernameConfig = (loginWithUsername)=>({
|
|
allowEmailLogin: false,
|
|
requireEmail: false,
|
|
requireUsername: true,
|
|
...loginWithUsername || {}
|
|
});
|
|
|
|
//# sourceMappingURL=defaults.js.map |