Fix folder assignment
This commit is contained in:
parent
582f8757b3
commit
1118ba1c2d
1 changed files with 11 additions and 1 deletions
|
@ -545,6 +545,8 @@ r.status_code
|
|||
|
||||
def create_password(self, post_obj):
|
||||
'''Create/add a password'''
|
||||
if 'folder' in post_obj:
|
||||
post_obj['folder'] = self.get_folder_id(post_obj['folder'])
|
||||
if not self.exists_password(post_obj):
|
||||
r = requests.post(
|
||||
f'{self.http}://{self.host}/index.php/apps/passwords/api/1.0/password/create',
|
||||
|
@ -623,6 +625,13 @@ r.status_code
|
|||
return True
|
||||
return False
|
||||
|
||||
def get_folder_id(self, folder_name):
|
||||
'''Get a folder id from the name'''
|
||||
for folder in self.list_passwords_folders():
|
||||
if folder['label'] == folder_name:
|
||||
return folder['id']
|
||||
return False
|
||||
|
||||
class NcPasswordClient:
|
||||
'''Nextcloud Password Client'''
|
||||
|
||||
|
@ -648,6 +657,7 @@ class NcPasswordClient:
|
|||
"api_token": api_token,
|
||||
"cse_password": cse_password,
|
||||
"timeout": timeout,
|
||||
"details": True,
|
||||
}
|
||||
self.nc = NextcloudHandler(params)
|
||||
|
||||
|
@ -699,7 +709,7 @@ class NcPasswordClient:
|
|||
store = passpy.store.Store()
|
||||
count = 0
|
||||
for item in store.find(''):
|
||||
if limit > -1 and limit > count:
|
||||
if limit == -1 or limit > count:
|
||||
obj = {
|
||||
"label": os.path.basename(item),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue