diff options
Diffstat (limited to 'static/index.js')
| -rw-r--r-- | static/index.js | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/static/index.js b/static/index.js index 870e3bb..c6388eb 100644 --- a/static/index.js +++ b/static/index.js @@ -29,15 +29,28 @@ const image_viewer = ImageViewer.new(); '/images/0010.jpg', ].forEach(url => image_viewer.add(url)) + const login = LoginView.new({ - onlogin: () => { - document.body.innerHTML = ''; - document.body.append( - main, - search, - month_select, - ) - } + onlogin: async (user, password) => { + if (await api.auth.login(user, password)) { + document.body.innerHTML = ''; + document.body.append( + main, + search, + month_select, + ) + } else { + login.comment = 'Incorrect username or password.'; + } + }, + + onpassword: async (user) => { + if (await api.auth.is_first_login(user)) { + login.comment = 'Please enter a new password.'; + } else { + login.comment = ''; + } + }, }); const search = Search.new({ @@ -73,7 +86,7 @@ const main = MainView.new({ main.active_view = image_viewer; month_select.show(); }, - onupload: () => api.upload_images(), + onupload: () => api.images.upload_to_timeline(), onshuffle: () => { main.active_kind = MainView.Kind.home; main.active_view = shuffle; |