@ollaid/native-sso 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,10 @@ export interface NativeSSOPageProps {
35
35
  logoUrl?: string;
36
36
  /** Masquer le footer "Propulsé par" */
37
37
  hideFooter?: boolean;
38
+ /** Route vers laquelle rediriger après un login réussi (via window.location.href) */
39
+ redirectAfterLogin?: string;
40
+ /** Route vers laquelle rediriger après un logout (via window.location.href) */
41
+ redirectAfterLogout?: string;
38
42
  }
39
- export declare function NativeSSOPage({ saasApiUrl, iamApiUrl, onLoginSuccess, onLogout, onOnboardingComplete, accountType, configPrefix, title, description, logoUrl, hideFooter, }: NativeSSOPageProps): import("react/jsx-runtime").JSX.Element;
43
+ export declare function NativeSSOPage({ saasApiUrl, iamApiUrl, onLoginSuccess, onLogout, onOnboardingComplete, accountType, configPrefix, title, description, logoUrl, hideFooter, redirectAfterLogin, redirectAfterLogout, }: NativeSSOPageProps): import("react/jsx-runtime").JSX.Element;
40
44
  export default NativeSSOPage;
package/dist/index.cjs CHANGED
@@ -4149,7 +4149,9 @@ function NativeSSOPage({
4149
4149
  title = "Un compte, plusieurs accès",
4150
4150
  description = "Connectez-vous avec votre compte Ollaid pour accéder à toutes les applications partenaires.",
4151
4151
  logoUrl,
4152
- hideFooter = false
4152
+ hideFooter = false,
4153
+ redirectAfterLogin,
4154
+ redirectAfterLogout
4153
4155
  }) {
4154
4156
  const [modal, setModal] = react.useState("none");
4155
4157
  const [showOnboarding, setShowOnboarding] = react.useState(false);
@@ -4218,8 +4220,9 @@ function NativeSSOPage({
4218
4220
  } else {
4219
4221
  setSession({ token, user: userObj });
4220
4222
  onLoginSuccess == null ? void 0 : onLoginSuccess(token, user);
4223
+ if (redirectAfterLogin) window.location.href = redirectAfterLogin;
4221
4224
  }
4222
- }, [onLoginSuccess]);
4225
+ }, [onLoginSuccess, redirectAfterLogin]);
4223
4226
  const handleOnboardingComplete = react.useCallback((data) => {
4224
4227
  if (!pendingSession) return;
4225
4228
  const updatedUser = { ...pendingSession.user, ...data };
@@ -4229,14 +4232,16 @@ function NativeSSOPage({
4229
4232
  setPendingSession(null);
4230
4233
  onOnboardingComplete == null ? void 0 : onOnboardingComplete(data);
4231
4234
  onLoginSuccess == null ? void 0 : onLoginSuccess(pendingSession.token, updatedUser);
4232
- }, [pendingSession, onLoginSuccess, onOnboardingComplete]);
4235
+ if (redirectAfterLogin) window.location.href = redirectAfterLogin;
4236
+ }, [pendingSession, onLoginSuccess, onOnboardingComplete, redirectAfterLogin]);
4233
4237
  const handleOnboardingSkip = react.useCallback(() => {
4234
4238
  if (!pendingSession) return;
4235
4239
  setShowOnboarding(false);
4236
4240
  setSession(pendingSession);
4237
4241
  setPendingSession(null);
4238
4242
  onLoginSuccess == null ? void 0 : onLoginSuccess(pendingSession.token, pendingSession.user);
4239
- }, [pendingSession, onLoginSuccess]);
4243
+ if (redirectAfterLogin) window.location.href = redirectAfterLogin;
4244
+ }, [pendingSession, onLoginSuccess, redirectAfterLogin]);
4240
4245
  const handleLogout = react.useCallback(() => {
4241
4246
  localStorage.removeItem(STORAGE.AUTH_TOKEN);
4242
4247
  localStorage.removeItem(STORAGE.TOKEN);
@@ -4245,7 +4250,8 @@ function NativeSSOPage({
4245
4250
  localStorage.removeItem(STORAGE.ALIAS_REFERENCE);
4246
4251
  setSession(null);
4247
4252
  onLogout == null ? void 0 : onLogout();
4248
- }, [onLogout]);
4253
+ if (redirectAfterLogout) window.location.href = redirectAfterLogout;
4254
+ }, [onLogout, redirectAfterLogout]);
4249
4255
  const containerStyle = {
4250
4256
  minHeight: "100vh",
4251
4257
  backgroundColor: COLORS.primary,