mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix restrictions for unknown users
This commit is contained in:
parent
c6cd432d92
commit
8e1b718060
@ -184,7 +184,9 @@ def manage_users(path=None):
|
||||
m.set_readonly(username, not readonly)
|
||||
|
||||
def change_restriction(username):
|
||||
r = m.restrictions(username) or {}
|
||||
r = m.restrictions(username)
|
||||
if r is None:
|
||||
raise SystemExit('The user {} does not exist'.format(username))
|
||||
if r['allowed_library_names']:
|
||||
prints(_('{} is currently only allowed to access the libraries named: {}').format(
|
||||
username, ', '.join(r['allowed_library_names'])))
|
||||
|
@ -153,6 +153,7 @@ class TestAuth(BaseTest):
|
||||
self.assertEqual(library_info('a')[0], {'l%d'%i:'l%d'%i for i in range(1, 4) if i == 3})
|
||||
self.assertEqual(library_info('a')[1], 'l3')
|
||||
self.assertRaises(HTTPForbidden, get_library, 'a', 'l1')
|
||||
self.assertRaises(HTTPForbidden, get_library, 'xxx')
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -197,7 +197,6 @@ class UserManager(object):
|
||||
with self.lock:
|
||||
r = self._restrictions.get(username)
|
||||
if r is None:
|
||||
r = self._restrictions[username] = parse_restriction('{}')
|
||||
for restriction, in self.conn.cursor().execute(
|
||||
'SELECT restriction FROM users WHERE name=?', (username,)):
|
||||
self._restrictions[username] = r = parse_restriction(restriction)
|
||||
|
Loading…
x
Reference in New Issue
Block a user