-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add fields to input client id and secret for login providers, fix collapse state on login UI #491
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c699471
Save the state of collapse when the page is refreshsed
HungNgien cecb81b
Add empty line
HungNgien 9f42842
Add fields to input Client id and Secret for login providers
HungNgien 6ee5781
Refactor code
HungNgien 1acce05
Add doc for social login
HungNgien 23c7cae
Fix flake8 warning
HungNgien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Social Login Setup | ||
================= | ||
|
||
To enable social login for providers, you first need to create an OAuth application on the provider's website. | ||
|
||
|
||
Google OAuth Application | ||
------------------------ | ||
Create an OAuth application on https://console.developers.google.com/ | ||
|
||
Instructions: | ||
- Follow the setup guide: https://medium.com/@tony.infisical/guide-to-using-oauth-2-0-to-access-google-apis-dead94d6866d | ||
- Set the callback URL to: `{domain}/accounts/google/login/callback/` | ||
- Add the client ID and client secret to admin settings | ||
|
||
|
||
Github OAuth Application | ||
----------------------- | ||
Create an OAuth application on https://github.com/settings/applications/new | ||
|
||
Instructions: | ||
- Set the callback URL to: `{domain}/accounts/github/login/callback/` | ||
- Add the client ID and client secret to admin settings | ||
|
||
|
||
MediaWiki OAuth Application | ||
-------------------------- | ||
To enable MediaWiki social login for your Pretix instance, you need to register an OAuth application with MediaWiki. | ||
|
||
Important Notes | ||
~~~~~~~~~~~~~~ | ||
- The OAuth application must be approved by a MediaWiki administrator | ||
- Until approved, only the application owner can log in | ||
|
||
Registration Steps | ||
~~~~~~~~~~~~~~~~~ | ||
1. Register your OAuth application at: | ||
https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose | ||
|
||
2. Callback URL Configuration | ||
- Set the OAuth "callback" URL to: `{domain}/accounts/mediawiki/login/callback/` | ||
- Example: `http://localhost:8000/accounts/mediawiki/login/callback/` | ||
|
||
3. Carefully read and follow the instructions on the registration page | ||
|
||
4. The registered application will return: | ||
- One consumer key | ||
- One consumer secret | ||
|
||
5. Add the consumer key and consumer secret to your Pretix admin settings | ||
|
||
After Approval | ||
~~~~~~~~~~~~~ | ||
Once approved, other users can log in to your Pretix instance using their MediaWiki account. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,8 @@ dependencies = [ | |
'eventyay-paypal @ git+https://[email protected]/fossasia/eventyay-tickets-paypal.git@master', | ||
'django_celery_beat==2.7.0', | ||
'cron-descriptor==1.4.5', | ||
'django-allauth[socialaccount]==65.3.0' | ||
'django-allauth[socialaccount]==65.3.0', | ||
'pydantic==2.10.4' | ||
] | ||
|
||
[project.optional-dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class ProviderConfig(BaseModel): | ||
state: bool = Field(description="State of this providers", default=False) | ||
client_id: str = Field(description="Client ID of this provider", default="") | ||
secret: str = Field(description="Secret of this provider", default="") | ||
|
||
|
||
class LoginProviders(BaseModel): | ||
mediawiki: ProviderConfig = Field(default_factory=ProviderConfig) | ||
github: ProviderConfig = Field(default_factory=ProviderConfig) | ||
google: ProviderConfig = Field(default_factory=ProviderConfig) | ||
|
||
class Config: | ||
extra = "forbid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const loginForm = document.getElementById('login-form'); | ||
const toggleLogin = document.getElementById('toggle-login'); | ||
const collapseStateKey = 'loginFormCollapseState'; | ||
|
||
// Restore state from localStorage | ||
const storedState = localStorage.getItem(collapseStateKey); | ||
console.log(storedState); | ||
if (storedState === 'open') { | ||
loginForm.classList.add('in'); | ||
} else { | ||
loginForm.classList.remove('in'); | ||
} | ||
|
||
// Save state on toggle | ||
toggleLogin.addEventListener('click', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: The collapse state is being stored based on the current class rather than the final state after transition. Consider using Bootstrap's 'shown.bs.collapse' and 'hidden.bs.collapse' events to ensure the correct state is stored after the transition completes. |
||
if (loginForm.classList.contains('in')) { | ||
localStorage.setItem(collapseStateKey, 'closed'); | ||
} else { | ||
localStorage.setItem(collapseStateKey, 'open'); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Add error handling for localStorage operations
localStorage might be unavailable in private browsing mode or if quota is exceeded. Consider wrapping these operations in try-catch blocks.
Suggested implementation: