add sample
This commit is contained in:
40
http-api/routes/me/__init__.py
Normal file
40
http-api/routes/me/__init__.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBCollection,
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
PrefixKey,
|
||||
)
|
||||
|
||||
import konviva
|
||||
from boto3clients import dynamodb_client
|
||||
from middlewares import AuthenticatedUser
|
||||
from settings import USER_TABLE
|
||||
|
||||
router = Router()
|
||||
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
collect = DynamoDBCollection(user_layer)
|
||||
|
||||
|
||||
LIMIT = 25
|
||||
|
||||
|
||||
@router.get('/')
|
||||
def me():
|
||||
user: AuthenticatedUser = router.context['user']
|
||||
|
||||
acls = collect.get_items(KeyPair(user.id, PrefixKey('acls')), limit=LIMIT)
|
||||
workspaces = collect.get_items(KeyPair(user.id, PrefixKey('orgs')), limit=LIMIT)
|
||||
|
||||
return {
|
||||
'acls': acls['items'],
|
||||
'workspaces': workspaces['items'],
|
||||
}
|
||||
|
||||
|
||||
@router.get('/konviva')
|
||||
def konviva_():
|
||||
user: AuthenticatedUser = router.context['user']
|
||||
token = konviva.token(user.email)
|
||||
|
||||
return {'redirect_uri': konviva.redirect_uri(token)}
|
||||
Reference in New Issue
Block a user