def get_identity(self, fn: AUTH) -> AUTH: """Register a function to identificate current user. User data: {id, fullName, avatar} """ self.auth['identityURL'] = f"{self.cfg.prefix}/ident" self.__ident__ = to_awaitable(fn) return fn
def setup(self, app: Application, *, name: str = None, **options): """Bind app and update the plugin's configuration.""" # allow to redefine the name for multi plugins with same type self.name = name or self.name # type: ignore self.app = app self.app.plugins[self.name] = self # Update configuration self.cfg.update_from_dict(dict(app.cfg), prefix=f"{self.name}_", exist_only=True) self.cfg.update_from_dict(options) # Register a middleware if self.middleware: self.app.middleware(to_awaitable(self.middleware)) # Bind startup if self.startup: self.app.on_startup(self.startup) # Bind shutdown if self.shutdown: self.app.on_shutdown(self.shutdown)
def locale_selector(self, fn: F) -> F: """Update self locale selector.""" self.__locale_selector = to_awaitable(fn) return fn
def dashboard(self, fn: AUTH) -> AUTH: """Register a function to render dashboard.""" self.__dashboard__ = to_awaitable(fn) return fn
def login(self, fn: AUTH) -> AUTH: """Register a function to login current user.""" self.auth['authorizeURL'] = f"{self.cfg.prefix}/login" self.__login__ = to_awaitable(fn) return fn