Try to ensure a fresh token on request
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
decentral1se 2021-06-13 17:43:26 +02:00
parent c45ee1647c
commit 777bd824a5
Signed by: decentral1se
GPG Key ID: 92DAD76BD9567B8A
2 changed files with 9 additions and 2 deletions

View File

@ -7,6 +7,13 @@ from fastapi import Depends, Request
from humanize import naturaldelta
async def fresh_token(request: Request):
"""Ensure fresh credentials for speaking to Keycloak."""
from keycloak_collective_portal.keycloak import init_keycloak
request.app.state.keycloak = init_keycloak()
async def logged_in(request: Request):
"""Ensure the user is logged in."""
from keycloak_collective_portal.exceptions import RequiresLoginException

View File

@ -6,7 +6,7 @@ from datetime import timedelta
from fastapi import APIRouter, Depends, Form, Request
from keycloak_collective_portal.dependencies import get_invites
from keycloak_collective_portal.dependencies import fresh_token, get_invites
router = APIRouter()
@ -50,7 +50,7 @@ async def register_invite(
)
@router.post("/form/keycloak/register")
@router.post("/form/keycloak/register", dependencies=[Depends(fresh_token)])
def form_keycloak_register(
request: Request,
first_name: str = Form(...),