51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from pyhooks import precall_register
|
|
|
|
send_message_hook = precall_register("send_message")
|
|
|
|
|
|
class Plugin:
|
|
def __init__(self, config=None, blueprint=None, permissions={}):
|
|
self.blueprint = blueprint
|
|
self.permissions = permissions
|
|
|
|
def install(self):
|
|
"""Installation routine
|
|
Is always called with Flask application context
|
|
"""
|
|
pass
|
|
|
|
|
|
class AuthPlugin(Plugin):
|
|
def login(self, user, pw):
|
|
"""Login routine, MUST BE IMPLEMENTED!
|
|
|
|
Args:
|
|
user: User class containing at least the uid
|
|
pw: given password
|
|
Returns:
|
|
Must return False if not found or invalid credentials, True if success
|
|
"""
|
|
raise NotImplementedError
|
|
|
|
def update_user(self, user):
|
|
"""If backend is using external data, then update this user instance with external data
|
|
|
|
Args:
|
|
user: User object
|
|
"""
|
|
pass
|
|
|
|
def modify_user(self, user, password, new_password=None):
|
|
"""If backend is using (writeable) external data, then update the external database with the user provided.
|
|
|
|
Args:
|
|
user: User object
|
|
password: Password (some backends need the current password for changes)
|
|
new_password: If set a password change is requested
|
|
Raises:
|
|
NotImplemented: If backend does not support this feature (or no password change)
|
|
BadRequest: Logic error, e.g. password is wrong.
|
|
Error: Other errors if backend went mad (are not handled and will result in a 500 error)
|
|
"""
|
|
raise NotImplemented
|