fix
This commit is contained in:
@@ -15,6 +15,12 @@ async def login_for_access_token(form_data: OAuth2PasswordRequestForm = Depends(
|
||||
detail="Incorrect username or password",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
if not user.is_admin:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Access denied. Only admins can login to the dashboard.",
|
||||
)
|
||||
access_token_expires = timedelta(minutes=auth_utils.ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||
access_token = auth_utils.create_access_token(
|
||||
data={"sub": user.username}, expires_delta=access_token_expires
|
||||
|
||||
Reference in New Issue
Block a user