Beispiel #1
0
            def wrapper(*args: List[Any], **kwargs: Dict[str, Any]) -> Any:
                if self.disabled:
                    a = JWTUser(
                        id=1,
                        impersonator=1,
                        type="users",
                        groups=[
                            JWTGroup(id="admin",
                                     name="admin",
                                     role=RoleType.ADMIN)
                        ],
                    )
                    g.user = a
                    return fn(*args, **kwargs)

                self.verify()
                user = JWTUser.from_dict(self.get_identity())
                g.user = user

                if not admin:
                    return fn(*args, **kwargs)

                if user.is_site_admin():
                    return fn(*args, **kwargs)
                else:
                    return "User unauthorized", 403
Beispiel #2
0
 def get_user_from_token(token: str) -> Optional[JWTUser]:
     token_data = decode_token(token)
     return JWTUser.from_dict(token_data["sub"])