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

fix+feat: fix infinte-loading due to non-call of callback and expose error message into frontend #2516

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ilsubyeega
Copy link
Contributor

@ilsubyeega ilsubyeega commented Apr 24, 2024

Summary

When a new user tried to sign up with social login, while registration disabled, the callback won't being called and would have to wait for a long time due to no callbacks. Also This PR also introduces append error parameter to /login frontend route to show the error of oauth.

  • Backend

    • return callback if registration has been closed.
    • Wrap passport.authenticate to handle the error message and then redirect into.
    • Expose error message by redirecting to /login?error=<MESSAGE>.
  • Frontend

    • Login.tsx: Extract ?error parameters from the URL and show it as an error message.
      • created customError state since error state always localized.
      • duplicated error element for customError usage.
  • Concerns

    • customError state is duplicated with error state. And might need to change names to avoid confusion.

Since I'm not used on express.js and React, Please let me know if i wrong of this

Change Type

Please delete any irrelevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Translation update
  • Documentation update

Testing

Please describe your test process and include instructions so that we can reproduce your test. If there are any important variables for your testing configuration, list them here.

Test Configuration:

I have no idea which unit test should i create.

Tested with ALLOW_SOCIAL_LOGIN=true and ALLOW_SOCIAL_REGISTRATION=false env.

Checklist

Please delete any irrelevant options.

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes
  • Any changes dependent on mine have been merged and published in downstream modules.

@ilsubyeega ilsubyeega marked this pull request as ready for review April 27, 2024 03:37
@ilsubyeega ilsubyeega changed the title (WIP) fix: return callbacks when social registration has been closed fix+feat: fix infinte-loading due to non-callback calling and expose error message into frontend Apr 27, 2024
@ilsubyeega ilsubyeega changed the title fix+feat: fix infinte-loading due to non-callback calling and expose error message into frontend fix+feat: fix infinte-loading due to non-call of callback and expose error message into frontend Apr 27, 2024
@danny-avila
Copy link
Owner

thanks! looks great, will test it and merge by end of weekend

Copy link
Owner

@danny-avila danny-avila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work as expected when social registration is disabled and attempting to use a new account. However, the issue exists when using an existing account.

image

api/server/routes/oauth.js Outdated Show resolved Hide resolved
client/src/components/Auth/Login.tsx Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants