51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
from backend.application.signin_hub import SignInHub
|
|
from pydantic import BaseModel
|
|
from fastapi import APIRouter
|
|
from common.token.token_manager import TokenManager
|
|
from fastapi import APIRouter, Depends
|
|
from fastapi.encoders import jsonable_encoder
|
|
from fastapi.responses import JSONResponse
|
|
from fastapi import Depends, HTTPException
|
|
from starlette.status import HTTP_401_UNAUTHORIZED
|
|
|
|
router = APIRouter()
|
|
token_manager = TokenManager()
|
|
# Web API
|
|
# update_user_flid
|
|
#
|
|
|
|
|
|
class RequestIn(BaseModel):
|
|
flid: str
|
|
|
|
|
|
@router.post(
|
|
"/update-new-user-flid",
|
|
operation_id="user_update_new_user_password",
|
|
summary="update the new user's freeleaps user id",
|
|
description="Freeleaps user ID(FLID) is a unique identifier to be used in git and other service across the platform",
|
|
response_description="signin result to indicate the next step for the client",
|
|
)
|
|
async def update_new_user_flid(
|
|
item: RequestIn,
|
|
current_user: dict = Depends(token_manager.get_current_user),
|
|
):
|
|
user_id = current_user.get("id")
|
|
|
|
if not user_id:
|
|
raise HTTPException(
|
|
status_code=HTTP_401_UNAUTHORIZED, detail="Could not validate credentials"
|
|
)
|
|
|
|
(
|
|
signed_in,
|
|
flid,
|
|
) = await SignInHub().update_new_user_flid(user_id, item.flid)
|
|
|
|
result = {
|
|
"signin_result": signed_in,
|
|
"flid": flid,
|
|
}
|
|
|
|
return JSONResponse(content=jsonable_encoder(result))
|