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
52 lines
2.0 KiB
Plaintext
52 lines
2.0 KiB
Plaintext
import { accountLockFields } from './baseFields/accountLock.js';
|
|
import { apiKeyFields } from './baseFields/apiKey.js';
|
|
import { baseAuthFields } from './baseFields/auth.js';
|
|
import { emailFieldConfig } from './baseFields/email.js';
|
|
import { sessionsFieldConfig } from './baseFields/sessions.js';
|
|
import { usernameFieldConfig } from './baseFields/username.js';
|
|
import { verificationFields } from './baseFields/verification.js';
|
|
export const getBaseAuthFields = (authConfig)=>{
|
|
const authFields = [];
|
|
if (authConfig.useAPIKey) {
|
|
authFields.push(...apiKeyFields);
|
|
}
|
|
if (!authConfig.disableLocalStrategy || typeof authConfig.disableLocalStrategy === 'object' && authConfig.disableLocalStrategy.enableFields) {
|
|
const emailField = {
|
|
...emailFieldConfig
|
|
};
|
|
let usernameField;
|
|
if (authConfig.loginWithUsername) {
|
|
usernameField = {
|
|
...usernameFieldConfig
|
|
};
|
|
if (typeof authConfig.loginWithUsername === 'object') {
|
|
if (authConfig.loginWithUsername.requireEmail === false) {
|
|
emailField.required = false;
|
|
}
|
|
if (authConfig.loginWithUsername.requireUsername === false) {
|
|
usernameField.required = false;
|
|
}
|
|
if (authConfig.loginWithUsername.allowEmailLogin === false) {
|
|
emailField.unique = false;
|
|
}
|
|
}
|
|
}
|
|
authFields.push(emailField);
|
|
if (usernameField) {
|
|
authFields.push(usernameField);
|
|
}
|
|
authFields.push(...baseAuthFields);
|
|
if (authConfig.verify) {
|
|
authFields.push(...verificationFields);
|
|
}
|
|
if (authConfig?.maxLoginAttempts && authConfig.maxLoginAttempts > 0) {
|
|
authFields.push(...accountLockFields);
|
|
}
|
|
if (authConfig.useSessions) {
|
|
authFields.push(sessionsFieldConfig);
|
|
}
|
|
}
|
|
return authFields;
|
|
};
|
|
|
|
//# sourceMappingURL=getAuthFields.js.map |