-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a signal to set locale cookie after login
Effectively undoes commit 0f8018e The approach of signals is required because of social login. See issue #171 for details as to why.
- Loading branch information
1 parent
1a008c9
commit 22402dd
Showing
5 changed files
with
11 additions
and
14 deletions.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
|
||
# this line required to get ServerConfig.ready() to run | ||
default_app_config = "cjworkbench.apps.ServerConfig" |
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 |
---|---|---|
|
@@ -6,4 +6,4 @@ class ServerConfig(AppConfig): | |
name = "cjworkbench" | ||
|
||
def ready(self): | ||
pass | ||
import cjworkbench.signals |
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,8 @@ | ||
from allauth.account.signals import user_logged_in | ||
from django.dispatch import receiver | ||
from cjworkbench.i18n import set_language_cookie | ||
|
||
|
||
@receiver(user_logged_in) | ||
def set_locale_cookie_after_login(sender, *, response, user, **kwargs): | ||
set_language_cookie(response, user.user_profile.locale_id) |
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 was deleted.
Oops, something went wrong.