Skip to content

Commit

Permalink
feat(objects): fix invite
Browse files Browse the repository at this point in the history
  • Loading branch information
Lowaiz committed Dec 13, 2023
1 parent 52e02cc commit f5fdb3b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/vaultwarden/clients/vaultwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def users(
if enabled is not None:
res = [u for u in res if u.UserEnabled == enabled]
if exclude_invited:
res = [u for u in res if u.Status != VaultwardenUserStatus.Invited]
res = [u for u in res if u.status != VaultwardenUserStatus.Invited]
if as_email_dict:
return {u.Email: u for u in res}
if as_uuid_dict:
Expand Down
18 changes: 14 additions & 4 deletions src/vaultwarden/models/bitwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,11 @@ def set_id(cls, v, info: FieldValidationInfo):
def invite(
self,
email,
collections: list[UUID] | list[UserCollection] | list[str] | None,
collections: list[UserCollection]
| list[OrganizationCollection]
| list[UUID]
| list[str]
| None,
access_all: bool = False,
user_type: OrganizationUserType = OrganizationUserType.User,
default_readonly: bool = False,
Expand All @@ -359,17 +363,23 @@ def invite(
exclude={"__all__": {"UserId"}},
)
else:
if isinstance(collections[0], OrganizationCollection):
coll_uuids = [str(coll.Id) for coll in collections]
elif isinstance(collections[0], UUID):
coll_uuids = [str(coll) for coll in collections]
else:
coll_uuids = collections
collections_payload = [
{
"id": collection_id,
"id": collection,
"readOnly": default_readonly,
"hidePasswords": default_hide_passwords,
}
for collection_id in collections
for collection in coll_uuids
]

payload = {
"email": [email],
"emails": [email],
"accessAll": access_all,
"type": user_type,
"Collections": collections_payload,
Expand Down
2 changes: 1 addition & 1 deletion src/vaultwarden/models/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class UserProfile(BaseModel, extra="allow"):
_Status: VaultwardenUserStatus = None

@property
def Status(self):
def status(self):
return self._Status


Expand Down

0 comments on commit f5fdb3b

Please sign in to comment.