Skip to content

Commit da6c263

Browse files
DH-5429 fixed auth not worked (#433)
1 parent e35ecdd commit da6c263

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

apps/ai/server/modules/auth/service.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ def login(self, user_request: UserRequest) -> UserResponse:
5353
),
5454
)
5555

56-
self.analytics.identify(
57-
user_org_id,
58-
OrganizationProperties(
59-
id=user_org_id,
60-
name=organization.name,
61-
owner=organization.owner,
62-
),
63-
)
56+
if organization.id:
57+
self.analytics.identify(
58+
user_org_id,
59+
OrganizationProperties(
60+
id=user_org_id,
61+
name=organization.name,
62+
owner=organization.owner,
63+
),
64+
)
6465

6566
return session_user

apps/ai/server/utils/analytics.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,18 @@ class EventType(BaseModel):
7070
user_event = UserEvent
7171

7272

73-
class UserProperties(BaseModel):
73+
class Properties(BaseModel):
7474
id: str | None
75+
76+
77+
class UserProperties(Properties):
7578
email: str | None
7679
name: str | None
7780
organization_id: str | None
7881
organization_name: str | None
7982

8083

81-
class OrganizationProperties(BaseModel):
82-
id: str | None
84+
class OrganizationProperties(Properties):
8385
name: str | None
8486
owner: str | None
8587

@@ -99,10 +101,10 @@ def track(self, user_id: str, event: str, properties: Event):
99101
properties=properties.dict(),
100102
)
101103

102-
def identify(self, user_id: str, properties: dict):
104+
def identify(self, user_id: str, properties: Properties):
103105
self.posthog.identify(
104106
user_id,
105-
properties=properties,
107+
properties=properties.dict(),
106108
)
107109

108110
def track_error(

0 commit comments

Comments
 (0)