mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Browser viewer: Show an error message when trying to use the Sync function without being logged in
This commit is contained in:
parent
8fa2c9a54f
commit
8e89d862fb
@ -148,7 +148,7 @@ def book_manifest(ctx, rd, book_id, fmt):
|
|||||||
ans = jsonlib.load(f)
|
ans = jsonlib.load(f)
|
||||||
ans['metadata'] = book_as_json(db, book_id)
|
ans['metadata'] = book_as_json(db, book_id)
|
||||||
user = rd.username or None
|
user = rd.username or None
|
||||||
ans['last_read_positions'] = db.get_last_read_positions(book_id, fmt, user)
|
ans['last_read_positions'] = db.get_last_read_positions(book_id, fmt, user) if user else []
|
||||||
return ans
|
return ans
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
if e.errno != errno.ENOENT:
|
if e.errno != errno.ENOENT:
|
||||||
@ -189,6 +189,8 @@ def get_last_read_position(ctx, rd, library_id, which):
|
|||||||
'''
|
'''
|
||||||
db = get_db(ctx, rd, library_id)
|
db = get_db(ctx, rd, library_id)
|
||||||
user = rd.username or None
|
user = rd.username or None
|
||||||
|
if not user:
|
||||||
|
raise HTTPNotFound('login required for sync')
|
||||||
ans = {}
|
ans = {}
|
||||||
allowed_book_ids = ctx.allowed_book_ids(rd, db)
|
allowed_book_ids = ctx.allowed_book_ids(rd, db)
|
||||||
for item in which.split('_'):
|
for item in which.split('_'):
|
||||||
|
@ -137,7 +137,10 @@ class SyncBook: # {{{
|
|||||||
return
|
return
|
||||||
self.overlay.hide()
|
self.overlay.hide()
|
||||||
if load_type is not 'load':
|
if load_type is not 'load':
|
||||||
error_dialog(_('Failed to fetch sync data'), _('Failed to download last read data from server, click "Show details" for more information.'), xhr.error_html)
|
if xhr.responseText is 'login required for sync':
|
||||||
|
error_dialog(_('Failed to fetch sync data'), _('You must setup user accounts and login to use the sync functionality'))
|
||||||
|
else:
|
||||||
|
error_dialog(_('Failed to fetch sync data'), _('Failed to download last read data from server, click "Show details" for more information.'), xhr.error_html)
|
||||||
return
|
return
|
||||||
data = JSON.parse(xhr.responseText)
|
data = JSON.parse(xhr.responseText)
|
||||||
book = self.overlay.view.book
|
book = self.overlay.view.book
|
||||||
|
Loading…
x
Reference in New Issue
Block a user