Skip to content

Commit 2f17574

Browse files
committed
Add documentation for registering custom logout callbacks
1 parent 29c83da commit 2f17574

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/configuring.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,27 @@ url_for('simplelogin.login', next='http://myothersite.com/')
9090
You can use the `from werkzeug.security import check_password_hash, generate_password_hash` utilities to encrypt passwords.
9191

9292
A working example is available in `manage.py` of [example app](https://github.com/flask-extensions/Flask-SimpleLogin/tree/main/example)
93+
94+
## Registering Custom Logout Callback(s)
95+
96+
You can define multiple custom logout callbacks to be executed after the user logs out using the `register_on_logout_callback` method:
97+
98+
```python
99+
from flask import Flask
100+
from flask_simplelogin import SimpleLogin
101+
102+
app = Flask(__name__)
103+
app.config['SECRET_KEY'] = 'something-secret'
104+
simple_login = SimpleLogin(app)
105+
106+
def my_post_logout_callback():
107+
print("User has logged out")
108+
109+
def another_post_logout_callback():
110+
print("Another action after logout")
111+
112+
simple_login.register_on_logout_callback(my_post_logout_callback)
113+
simple_login.register_on_logout_callback(another_post_logout_callback)
114+
```
115+
116+
The callbacks will be executed in the order they were registered.

0 commit comments

Comments
 (0)