Fatih Degirmenci | c2a4601 | 2019-09-30 12:07:45 +0200 | [diff] [blame] | 1 | from functools import wraps |
| 2 | from flask import flash, redirect, url_for |
| 3 | from flask_login import current_user |
| 4 | |
| 5 | def check_confirmed(func): |
| 6 | @wraps(func) |
| 7 | def decorated_function(*args, **kwargs): |
| 8 | if not current_user.confirmed: |
| 9 | return redirect(url_for('user.unconfirmed')) |
| 10 | return func(*args, **kwargs) |
| 11 | |
| 12 | return decorated_function |
| 13 | |
| 14 | def check_sshkey(func): |
| 15 | @wraps(func) |
| 16 | def decorated_function(*args, **kwargs): |
Fatih Degirmenci | 89e4ac9 | 2019-10-01 07:41:29 +0000 | [diff] [blame] | 17 | if current_user.ssh_public_key is None: |
| 18 | return redirect(url_for('user.profile')) |
| 19 | if not current_user.ssh_public_key: |
Fatih Degirmenci | c2a4601 | 2019-09-30 12:07:45 +0200 | [diff] [blame] | 20 | return redirect(url_for('user.profile')) |
| 21 | return func(*args, **kwargs) |
| 22 | |
| 23 | return decorated_function |