forked from bbangert/velruse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds before and after login view call hooks, which are useful for sys…
…tems using velruse as a plugin. It allows the plugin user to modify any information before or after the login view is called. For example, before or after the login view is hit, one could capture the referrer location so that they can send the authenticated user back to where they came from.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Custom events for identity provider login.""" | ||
import functools | ||
from pyramid.events import NewRequest | ||
|
||
def with_events(before=None, after=None): | ||
"""Decorator to create event book ends on a method.""" | ||
def decorator(method): | ||
@functools.wraps(method) | ||
def new_method(obj, request): | ||
request.registry.notify(before(request)) | ||
response = method(obj, request) | ||
request.registry.notify(after(request)) | ||
return response | ||
return new_method | ||
return decorator | ||
|
||
|
||
class BeforeLogin(NewRequest): | ||
"""Used to tap into the request before | ||
the identity provider logic is run. | ||
""" | ||
|
||
|
||
class AfterLogin(NewRequest): | ||
"""Used to tap into the request after | ||
the identity provider logic has run. | ||
""" |
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