logto-io / logto

🧑‍🚀 The better identity infrastructure for developers and the open-source alternative to Auth0.
https://logto.io
Mozilla Public License 2.0
8.31k stars 406 forks source link

refactor(experience): use button loading for social sign-in #6316

Closed xiaoyijun closed 1 month ago

xiaoyijun commented 1 month ago

Summary

This PR refactors the social sign-in and single sign-on (SSO) functionality to incorporate button loading states, improving user feedback during authentication processes.

By introducing the global redirection mechanism,this PR also fix a bug that the social connector button can be click more than once before 3rd-party sign-in page redirection. (Refer to this Slack thread: https://silverhand-io.slack.com/archives/C05TA6PH1T9/p1721376692062789)

Key changes:

  1. Added loading states for social sign-in and SSO buttons

    • Implemented in SocialSignInList and SingleSignOnConnectors components
    • Provides visual feedback during authentication processes
  2. Enhanced useGlobalRedirectTo hook

    • Added options for clearing interaction context
    • Allows choosing between window.location.replace and window.location.assign
    • Improves flexibility for various redirection scenarios
  3. Updated social sign-in and SSO flows

    • Integrated useGlobalRedirectTo for more consistent redirection handling

Testing

Social sign-in: image

image

SSO:

image

image

Checklist

github-actions[bot] commented 1 month ago

COMPARE TO master

Total Size Diff :chart_with_upwards_trend: +2.16 KB

Diff by File |Name|Diff| |---|---| |packages/experience/src/containers/SocialSignInList/index.tsx|:chart_with_upwards_trend: +350 Bytes| |packages/experience/src/containers/SocialSignInList/use-social.ts|:chart_with_upwards_trend: +235 Bytes| |packages/experience/src/hooks/use-global-redirect-to.ts|:chart_with_upwards_trend: +1.04 KB| |packages/experience/src/hooks/use-single-sign-on.ts|:chart_with_upwards_trend: +191 Bytes| |packages/experience/src/pages/SingleSignOnConnectors/index.tsx|:chart_with_upwards_trend: +368 Bytes|