Skip to content

Commit

Permalink
[FEATURE][WS-1698]raise unauthorized exception when user is not active
Browse files Browse the repository at this point in the history
  • Loading branch information
chloechen committed Oct 11, 2022
1 parent 15418f1 commit 5677c53
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion awesome_sso/service/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from typing import Optional

import jwt
from awesome_exception.exceptions import BadRequest, NotFound, Unauthorized
from beanie import PydanticObjectId
from fastapi import Cookie, Depends, Security
from fastapi.logger import logger
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from pydantic import BaseModel

from awesome_exception.exceptions import BadRequest, NotFound, Unauthorized
from awesome_sso.service.settings import Settings
from awesome_sso.service.user.schema import AwesomeUserType, RegisterModel
from awesome_sso.util.constant import MOCK_USER_ID
Expand Down
2 changes: 1 addition & 1 deletion awesome_sso/service/route.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from datetime import timedelta

from awesome_exception.exceptions import BadRequest, HTTPException, InternalServerError
from beanie import DeleteRules
from fastapi import APIRouter, Depends, Response
from fastapi.logger import logger

from awesome_exception.exceptions import BadRequest, HTTPException, InternalServerError
from awesome_sso.service.depends import get_sso_user_id, sso_registration, sso_user
from awesome_sso.service.settings import Settings
from awesome_sso.service.user.schema import AccessToken, AwesomeUserType, RegisterModel
Expand Down
4 changes: 3 additions & 1 deletion awesome_sso/service/user/sync_user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import requests
from awesome_exception.exceptions import InternalServerError
from awesome_exception.exceptions import InternalServerError, Unauthorized

from awesome_sso.service.settings import Settings
from awesome_sso.service.user.schema import AwesomeUserType
Expand All @@ -12,6 +12,8 @@ async def sync_user(user: AwesomeUserType):
timeout=5,
)
resp.close()
if resp.status_code == 401:
raise Unauthorized(f"user {user.email} is not active")
if resp.status_code / 2 != 100:
raise InternalServerError(
"update vendor info failed: " + str(resp.content.decode("utf-8"))
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "awesome-sso"
version = "0.5.0"
version = "0.5.1"
license = "Apache-2.0"
readme = "README.md"
description = "sso general utility for services connected to sso"
Expand Down

0 comments on commit 5677c53

Please sign in to comment.