-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
188 additions
and
45 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
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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
from django.contrib import messages | ||
from django.http import HttpRequest | ||
|
||
from allauth.account.internal.stagekit import clear_login | ||
|
||
|
||
def logout(request: HttpRequest) -> None: | ||
from allauth.account.adapter import get_adapter | ||
|
||
adapter = get_adapter() | ||
adapter.add_message(request, messages.SUCCESS, "account/messages/logged_out.txt") | ||
adapter.logout(request) | ||
if request.user.is_authenticated: | ||
adapter = get_adapter() | ||
adapter.add_message( | ||
request, messages.SUCCESS, "account/messages/logged_out.txt" | ||
) | ||
adapter.logout(request) | ||
clear_login(request) |
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,31 @@ | ||
from typing import Optional | ||
|
||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse | ||
|
||
from allauth.account.stages import LoginStage, LoginStageController | ||
|
||
|
||
def get_pending_stage(request) -> Optional[LoginStage]: | ||
from allauth.account.utils import unstash_login | ||
|
||
stage = None | ||
if not request.user.is_authenticated: | ||
login = unstash_login(request, peek=True) | ||
if login: | ||
ctrl = LoginStageController(request, login) | ||
stage = ctrl.get_pending_stage() | ||
return stage | ||
|
||
|
||
def redirect_to_pending_stage(request, stage: LoginStage): | ||
if stage.urlname: | ||
return HttpResponseRedirect(reverse(stage.urlname)) | ||
clear_login(request) | ||
return HttpResponseRedirect(reverse("account_login")) | ||
|
||
|
||
def clear_login(request): | ||
from allauth.account.internal.flows.login import LOGIN_SESSION_KEY | ||
|
||
request.session.pop(LOGIN_SESSION_KEY, None) |
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
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
Oops, something went wrong.