Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions blocks/identity-block/components/login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ const useLogin = ({
if (window?.location?.search) {
const searchParams = new URLSearchParams(window.location.search.substring(1));

//redirectURL could have additional params
// redirectURL could have additional params
const params = ["paymentMethodID"];
const aditionalParams = params.map((p) => {
const paramExist = searchParams.has(p)
if(paramExist){
return {[p]:searchParams.get(p)}
}
const aditionalParams = params.filter((p) => {
const paramExist = searchParams.has(p);

return paramExist;
})

const fullURL = searchParams.get("redirect") ? appendURLParams(searchParams.get("redirect"), aditionalParams.filter(item => item !== undefined)) : null;
Expand All @@ -37,7 +36,9 @@ const useLogin = ({
}

if (redirectToPreviousPage && document?.referrer) {
setRedirectToURL(document.referrer);
const redirectUrl = new URL(document.referrer);

setRedirectToURL(`${redirectUrl.pathname}${redirectUrl.search}`);
}
}, [redirectQueryParam, redirectToPreviousPage]);

Expand All @@ -56,6 +57,7 @@ const useLogin = ({
const checkLoggedInStatus = async () => {
const isLoggedIn = await Identity.isLoggedIn();
const validatedLoggedInPageLoc = validateURL(loggedInPageLocation);

if (isLoggedIn) {
if (isOIDC) {
loginByOIDC();
Expand All @@ -67,7 +69,7 @@ const useLogin = ({
if (Identity && !isAdmin) {
checkLoggedInStatus();
}
}, [Identity, redirectQueryParam, loggedInPageLocation, isAdmin]);
}, [Identity, redirectQueryParam, loggedInPageLocation, isAdmin, loginByOIDC, isOIDC]);

return {
loginRedirect: redirectQueryParam || redirectToURL,
Expand Down
8 changes: 6 additions & 2 deletions blocks/identity-block/components/login/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ describe("useLogin()", () => {
beforeEach(() => {
Object.defineProperty(window, "location", {
writable: true,
value: {
href: 'http://localhost',
search: ''
}
});
useIdentity.mockImplementation(() => ({
isInitialized: true,
Expand Down Expand Up @@ -68,14 +72,14 @@ describe("useLogin()", () => {
});

it("uses document referrer", async () => {
const referrerURL = "http://referrer.com";
const referrerURL = "http://referrer.com/article/1234";
Object.defineProperty(document, "referrer", {
value: referrerURL,
configurable: true,
});
await render(<Test />);
fireEvent.click(screen.getByRole("button"));
expect(window.location).toBe(referrerURL);
expect(window.location).toBe("/article/1234");
delete document.referrer;
});

Expand Down
6 changes: 6 additions & 0 deletions blocks/subscriptions-block/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,9 @@
@include scss.block-properties("paywall-subscription-dialog");
}
}

@media (min-width: 320px) and (max-width: 480px) {
.b-paywall__overlay {
inset-block-start: initial;
}
}