fix
This commit is contained in:
46
http-api/app/routes/settings/__init__.py
Normal file
46
http-api/app/routes/settings/__init__.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBCollection,
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
PrefixKey,
|
||||
)
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from conf import USER_TABLE
|
||||
import konviva
|
||||
from middlewares import User
|
||||
|
||||
router = Router()
|
||||
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
user_collect = DynamoDBCollection(user_layer)
|
||||
|
||||
|
||||
LIMIT = 25
|
||||
|
||||
|
||||
@router.get('/', include_in_schema=False)
|
||||
def settings():
|
||||
user: User = router.context['user']
|
||||
acls = user_collect.query(
|
||||
KeyPair(user.id, PrefixKey('acls')),
|
||||
limit=LIMIT,
|
||||
)
|
||||
tenants = user_collect.query(
|
||||
KeyPair(user.id, PrefixKey('orgs')),
|
||||
limit=LIMIT,
|
||||
)
|
||||
|
||||
return {
|
||||
'acls': acls['items'],
|
||||
# Note: Ensure compatibility with search on React's tenant menu
|
||||
'tenants': [x | {'id': x['sk'], 'sk': '0'} for x in tenants['items']],
|
||||
}
|
||||
|
||||
|
||||
@router.get('/konviva', include_in_schema=False)
|
||||
def konviva_():
|
||||
user: User = router.context['user']
|
||||
token = konviva.token(user.email)
|
||||
|
||||
return {'redirect_uri': konviva.redirect_uri(token)}
|
||||
Reference in New Issue
Block a user