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

Create speaker account with SSO as part of the answer to Call for Proposals #258

Merged
merged 9 commits into from
Jan 21, 2025

Conversation

HungNgien
Copy link
Contributor

@HungNgien HungNgien commented Jan 15, 2025

Description:

  • Implement Register Speaker Account button
  • Make Login with SSO button to return to previous page after login

image
The user is now required to login before submitting a proposal

This PR resolves #257

Summary by Sourcery

New Features:

  • Speakers can now create an account directly from the Call for Proposals page.

@HungNgien HungNgien marked this pull request as ready for review January 15, 2025 04:44
Copy link

sourcery-ai bot commented Jan 15, 2025

Reviewer's Guide by Sourcery

This pull request implements the "Register Speaker Account" button and modifies the "Login with SSO" button to redirect users back to the previous page after login. This addresses the issue where users were not able to create an account or login via SSO to submit a proposal.

Sequence diagram for the updated SSO login flow

sequenceDiagram
    actor User
    participant Browser
    participant App
    participant SSOProvider

    User->>Browser: Click 'Login with SSO'
    Browser->>App: GET /login/ with next_url
    App->>App: Store next_url in session
    App->>SSOProvider: Redirect to authorization URL
    SSOProvider-->>Browser: Show login page
    User->>SSOProvider: Enter credentials
    SSOProvider-->>App: OAuth callback
    App->>App: Process OAuth response
    App->>App: Create/update user
    App->>App: Retrieve next_url from session
    App-->>Browser: Redirect to next_url
    Browser-->>User: Show original page
Loading

File-Level Changes

Change Details Files
Added "Register Speaker Account" button and functionality.
  • Implemented the register function in auth.py to handle user registration and redirect to the previous page using the next parameter.
  • Added a new URL pattern for the registration view in urls.py.
  • Included the "Register Speaker Account" button in the auth.html template.
  • Added conditional rendering of the submission form in submission_base.html based on user authentication status. If not authenticated, display login and registration options with a message explaining the requirement to be logged in to submit a proposal, along with the login/registration buttons using the auth.html template with the next_url parameter set to the current page URL.
src/pretalx/eventyay_common/views/auth.py
src/pretalx/eventyay_common/urls.py
src/pretalx/common/templates/common/auth.html
src/pretalx/cfp/templates/cfp/event/submission_base.html
Modified "Login with SSO" button to redirect to the previous page after login.
  • Refactored the oauth2_login_view to OAuth2LoginView class-based view and added the next parameter handling to store the URL in the session.
  • Modified the oauth2_callback function to redirect to the stored next URL after successful login.
  • Added next_url parameter to the "Login with SSO" button URL in auth.html template.
  • Added next_url parameter to the login and invitation templates to preserve the redirect URL after login.
src/pretalx/eventyay_common/views/auth.py
src/pretalx/common/templates/common/auth.html
src/pretalx/cfp/templates/cfp/event/login.html
src/pretalx/orga/templates/orga/auth/login.html
src/pretalx/orga/templates/orga/invitation.html

Assessment against linked issues

Issue Objective Addressed Explanation
#257 Support speaker account registration process with SSO option
#257 Implement login flow that allows returning to previous page after authentication
#257 Require user login before submitting a proposal

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @HungNgien - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Validate next_url parameter to prevent open redirect vulnerabilities (link)
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🔴 Security: 1 blocking issue, 1 other issue
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

src/pretalx/eventyay_common/views/auth.py Show resolved Hide resolved
src/pretalx/eventyay_common/views/auth.py Outdated Show resolved Hide resolved
@HungNgien HungNgien marked this pull request as draft January 15, 2025 07:43
@HungNgien HungNgien marked this pull request as ready for review January 15, 2025 09:19
Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@mariobehling mariobehling merged commit 71f0611 into fossasia:development Jan 21, 2025
6 of 8 checks passed
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.

Create speaker account with SSO as part of the answer to Call for Proposals
3 participants