Skip to content

Commit

Permalink
feat: Add url as a login and logout callbackUrl parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTolmay committed Jun 24, 2022
1 parent 9c13bd6 commit 78d099a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/client/src/auth/createAuthMethods.js
Expand Up @@ -17,10 +17,12 @@
import { type, urlQuery as urlQueryFn } from '@lowdefy/helpers';

function getCallbackUrl({ lowdefy, callbackUrl = {} }) {
const { home, pageId, urlQuery } = callbackUrl;
const { home, pageId, urlQuery, url } = callbackUrl;

if ([!home, !pageId].filter((v) => !v).length > 1) {
throw Error(`Invalid Link: To avoid ambiguity, only one of 'home' or 'pageId' can be defined.`);
if ([!home, !pageId, !url].filter((v) => !v).length > 1) {
throw Error(
`Invalid Link: To avoid ambiguity, only one of 'home', 'pageId' or 'url' can be defined.`
);
}
const query = type.isNone(urlQuery) ? '' : `${urlQueryFn.stringify(urlQuery)}`;

Expand All @@ -30,6 +32,9 @@ function getCallbackUrl({ lowdefy, callbackUrl = {} }) {
if (type.isString(pageId)) {
return `/${pageId}${query ? `?${query}` : ''}`;
}
if (type.isString(url)) {
return `${url}${query ? `?${query}` : ''}`;
}

return undefined;
}
Expand Down

0 comments on commit 78d099a

Please sign in to comment.