Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow returning null from getRedirectionURL override #766

Merged
merged 24 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [0.35.8] - 2023-11-24
## [0.36.0] - 2023-12-01

### Changes

rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
- `getRedirectionURL` now supports returning `null` to prevent automatic redirection, useful for customizing the behavior after successful sign-in or sign-up.
- `getRedirectionURL` now supports returning `null` to prevent automatic redirection, useful for customizing the behavior after successful sign-in or sign-up. Typically, this is used if you want to embed the sign in / up component in a popup and want to just dismiss the popup post login.
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved

Here's an example of how to use this:

Expand All @@ -25,7 +25,21 @@ EmailPassword.init({
});
```

## [0.35.7] - 2023-11-16
### Breaking changes

- The `CloseTabScreen` [component](https://supertokens.com/img/otp-magic-link-same-time.png), previously featured in the passwordless recipe visible when a user signs in from another tab using a magic link, has been removed. Instead, users will now be automatically redirected to the specified return value from the `getRedirectionURL` function if a session exists. In cases where `getRedirectionURL` is not provided, the default redirection path is set to `/`. If you were [overriding](https://supertokens.com/docs/passwordless/advanced-customizations/react-component-override/usage) this component using `PasswordlessCloseTabScreen_Override`, you no longer need to do so.

- If your workflow involves custom validation, such as Phone Number verification, after signing in, ensure your code aligns with the updated examples found in [with-phone-password](https://github.com/supertokens/supertokens-auth-react/tree/master/examples/with-phone-password) or [with-thirdpartyemailpassword-passwordless](https://github.com/supertokens/supertokens-auth-react/tree/master/examples/with-thirdpartyemailpassword-passwordless).

Changes:

- The need to manually set `props.featureState.successInAnotherTab` to `false` to avoid displaying the `CloseTabScreen` component has been eliminated.
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved

## [0.35.8] - 2023-11-26

- Fixes `inputComponent` props to make them non optional. This is in the context of customizing the sign up form to add custom react components.

## [0.35.7] - 2023-11-24

### Added

Expand Down
9 changes: 9 additions & 0 deletions examples/for-tests-react-16/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ function getEmailPasswordConfigs({ disableDefaultUI }) {
console.log(`ST_LOGS EMAIL_PASSWORD GET_REDIRECTION_URL ${context.action}`);
if (context.action === "SUCCESS") {
setIsNewUserToStorage("emailpassword", context.isNewRecipeUser);
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
return null;
}
return context.redirectToPath || "/dashboard";
}
},
Expand Down Expand Up @@ -733,6 +736,9 @@ function getThirdPartyPasswordlessConfigs({ staticProviderList, disableDefaultUI
console.log(`ST_LOGS THIRDPARTYPASSWORDLESS GET_REDIRECTION_URL ${context.action}`);
if (context.action === "SUCCESS") {
setIsNewUserToStorage("thirdpartypasswordless", context.isNewRecipeUser);
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
return null;
}
return context.redirectToPath || "/dashboard";
}
},
Expand Down Expand Up @@ -817,6 +823,9 @@ function getPasswordlessConfigs({ disableDefaultUI }) {
console.log(`ST_LOGS PASSWORDLESS GET_REDIRECTION_URL ${context.action}`);
if (context.action === "SUCCESS") {
setIsNewUserToStorage("passwordless", context.isNewRecipeUser);
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
return null;
}
return context.redirectToPath || "/dashboard";
}
},
Expand Down
2 changes: 2 additions & 0 deletions examples/for-tests-react-16/src/testContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function getTestContext() {
staticProviderList: localStorage.getItem("staticProviderList"),
mockTenantId: localStorage.getItem("mockTenantId"),
clientType: localStorage.getItem("clientType") || undefined,
disableRedirectionAfterSuccessfulSignInUp:
localStorage.getItem("disableRedirectionAfterSuccessfulSignInUp") === "true",
};
return ret;
}
Expand Down
3 changes: 3 additions & 0 deletions examples/for-tests/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,9 @@ function getThirdPartyPasswordlessConfigs({ staticProviderList, disableDefaultUI
console.log(`ST_LOGS THIRDPARTYPASSWORDLESS GET_REDIRECTION_URL ${context.action}`);
if (context.action === "SUCCESS") {
setIsNewUserToStorage("thirdpartypasswordless", context.isNewRecipeUser);
if (testContext.disableRedirectionAfterSuccessfulSignInUp) {
return null;
}
return context.redirectToPath || "/dashboard";
}
},
Expand Down
1 change: 1 addition & 0 deletions examples/with-one-login-per-subdomain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
127.0.0.1 tenant1.example.com
127.0.0.1 tenant2.example.com
127.0.0.1 tenant3.example.com
127.0.0.1 example.com
```

## Available Scripts
Expand Down
3 changes: 0 additions & 3 deletions examples/with-phone-password/src/PhoneVerification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const CustomSignInUpTheme: typeof SignInUpTheme = (props) => {
};
}, []);

// If this was active, we'd not show the OTP screen because it'd detect an active session.
props.featureState.successInAnotherTab = false;

if (showDefaultUI) {
return <SignInUpTheme {...props} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const CustomSignInUpTheme: typeof PasswordlessPreBuiltUI.SignInUpTheme = (props)
};
}, []);

// If this was active, we'd not show the OTP screen because it'd detect an active session.
props.featureState.successInAnotherTab = false;

if (showDefaultUI) {
return <PasswordlessPreBuiltUI.SignInUpTheme {...props} />;
}
Expand Down
57 changes: 0 additions & 57 deletions lib/build/checkedRoundIcon.js → lib/build/emailLargeIcon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 59 additions & 3 deletions lib/build/emailverificationprebuiltui.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions lib/build/genericComponentOverrideContext.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions lib/build/passwordless-shared2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading