diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-14 21:55:59 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-11-14 21:55:59 +0100 |
| commit | 3f18f02d07802d1fc705a500e5978a9b3cb2e751 (patch) | |
| tree | 283970a2f5a693706456b853c550eeaa669b5d72 /static/index.js | |
| parent | 351ad457f0ff95e20301a146b8c88a8f0f659aa1 (diff) | |
implement login
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; |