-
Notifications
You must be signed in to change notification settings - Fork 1
Launchpad MP (501314) - r00ta/openfga-users-to-groups-endpoints #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Copyright 2026 Canonical Ltd. This software is licensed under the | ||
| # GNU Affero General Public License version 3 (see the file LICENSE). | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
|
|
||
| class UserGroupMemberRequest(BaseModel): | ||
| user_id: int = Field(description="The ID of the user to add to the group.") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Copyright 2026 Canonical Ltd. This software is licensed under the | ||
| # GNU Affero General Public License version 3 (see the file LICENSE). | ||
|
|
||
| from typing import Self | ||
|
|
||
| from pydantic import BaseModel | ||
|
|
||
| from maasservicelayer.models.usergroup_members import UserGroupMember | ||
|
|
||
|
|
||
| class UserGroupMemberResponse(BaseModel): | ||
| kind = "UserGroupMember" | ||
| user_id: int | ||
| username: str | ||
| email: str | ||
|
|
||
| @classmethod | ||
| def from_model(cls, member: UserGroupMember) -> Self: | ||
| return cls( | ||
| user_id=member.id, | ||
| username=member.username, | ||
| email=member.email, | ||
| ) | ||
|
|
||
|
|
||
| class UserGroupMembersListResponse(BaseModel): | ||
| kind = "UserGroupMembersList" | ||
| items: list[UserGroupMemberResponse] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -185,6 +185,7 @@ func addUsersToGroup(ctx context.Context, tx *sql.Tx, administratorGroupID int64 | |||||
| selectStmt, selectArgs, err := builder. | ||||||
| Select("id", "is_superuser"). | ||||||
| From("auth_user"). | ||||||
| Where(sq.Or{sq.NotEq{"username": "MAAS"}, sq.NotEq{"username": "maas-init-node"}}). // Ignore the internal users | ||||||
|
||||||
| Where(sq.Or{sq.NotEq{"username": "MAAS"}, sq.NotEq{"username": "maas-init-node"}}). // Ignore the internal users | |
| Where(sq.NotEq{"username": []string{"MAAS", "maas-init-node"}}). // Ignore the internal users |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserGroupMemberResponse.emailis typed asstr, but member emails can be null (auth_user.emailis nullable). This will cause response validation errors when serializing members without an email. Change the field tostr | None(and keepfrom_modelpassing through the value).