diff --git a/src/auth/operations/local/index.js b/src/auth/operations/local/index.js new file mode 100644 index 0000000000..624042d20e --- /dev/null +++ b/src/auth/operations/local/index.js @@ -0,0 +1,7 @@ +const register = require('./register'); +const login = require('./login'); + +module.exports = { + register, + login, +}; diff --git a/src/auth/operations/local/login.js b/src/auth/operations/local/login.js new file mode 100644 index 0000000000..b87bed7bd5 --- /dev/null +++ b/src/auth/operations/local/login.js @@ -0,0 +1,28 @@ +async function login(options) { + const { + collection: collectionSlug, + res, + depth, + locale, + fallbackLocale, + data, + } = options; + + const collection = this.collections[collectionSlug]; + + return this.operations.collections.auth.login({ + depth, + collection, + overrideAccess: true, + data, + req: { + payloadAPI: 'local', + locale, + fallbackLocale, + payload: this, + }, + res, + }); +} + +module.exports = login; diff --git a/src/auth/operations/local/register.js b/src/auth/operations/local/register.js new file mode 100644 index 0000000000..87b0ab6bb6 --- /dev/null +++ b/src/auth/operations/local/register.js @@ -0,0 +1,26 @@ +async function register(options) { + const { + collection: collectionSlug, + depth, + locale, + fallbackLocale, + data, + } = options; + + const collection = this.collections[collectionSlug]; + + return this.operations.collections.auth.register({ + depth, + data, + collection, + overrideAccess: true, + req: { + payloadAPI: 'local', + locale, + fallbackLocale, + payload: this, + }, + }); +} + +module.exports = register; diff --git a/src/auth/operations/login.js b/src/auth/operations/login.js index 5eb9647d1a..5bf69c1cc2 100644 --- a/src/auth/operations/login.js +++ b/src/auth/operations/login.js @@ -86,7 +86,7 @@ async function login(args) { cookieOptions.secure = true; } - if (args.req.headers.origin && args.req.headers.origin.indexOf('localhost') === -1) { + if (args.req.headers && args.req.headers.origin && args.req.headers.origin.indexOf('localhost') === -1) { let domain = args.req.headers.origin.replace('https://', ''); domain = domain.replace('http://', ''); cookieOptions.domain = domain; diff --git a/src/auth/operations/refresh.js b/src/auth/operations/refresh.js index 9dd7acf48e..b4353fedcf 100644 --- a/src/auth/operations/refresh.js +++ b/src/auth/operations/refresh.js @@ -41,7 +41,7 @@ async function refresh(args) { cookieOptions.secure = true; } - if (args.req.headers.origin && args.req.headers.origin.indexOf('localhost') === -1) { + if (args.req.headers && args.req.headers.origin && args.req.headers.origin.indexOf('localhost') === -1) { let domain = args.req.headers.origin.replace('https://', ''); domain = domain.replace('http://', ''); cookieOptions.domain = domain; diff --git a/src/auth/operations/resetPassword.js b/src/auth/operations/resetPassword.js index e3d9cbeab0..67b711e734 100644 --- a/src/auth/operations/resetPassword.js +++ b/src/auth/operations/resetPassword.js @@ -80,7 +80,7 @@ async function resetPassword(args) { cookieOptions.secure = true; } - if (args.req.headers.origin && args.req.headers.origin.indexOf('localhost') === -1) { + if (args.req.headers && args.req.headers.origin && args.req.headers.origin.indexOf('localhost') === -1) { let domain = args.req.headers.origin.replace('https://', ''); domain = domain.replace('http://', ''); cookieOptions.domain = domain; diff --git a/src/client/components/forms/field-types/Group/index.js b/src/client/components/forms/field-types/Group/index.js index 46d2a30bde..4ab36c4f1b 100644 --- a/src/client/components/forms/field-types/Group/index.js +++ b/src/client/components/forms/field-types/Group/index.js @@ -29,8 +29,9 @@ const Group = (props) => {
-

{label}

- + {label && ( +

{label}

+ )}