Spaces:
JCTN
/
Build error

Adrien Denat Eliott C. victor HF Staff commited on
Commit
64d3841
·
unverified ·
1 Parent(s): 31ef570

Login flow (#193)

Browse files

* replace EthicsModal by LoginModal and start binding auth logic

* start implementing login modal + give a try to @auth /sveltekit

using Github oauth as a test

* start custom auth implementation instead of auth.js for consistency with moon-landing

* fetch user data from provider

* add migration from anonymous to user + bind frontend

* add missing auth secret + only migrate conversations for pre-existing users

* remove email scope as it's not needed

Co-authored-by: Eliott C. <coyotte508@gmail.com>

* no need to define .well-known path

Co-authored-by: Eliott C. <coyotte508@gmail.com>

* use env var for hf hub website url

* move sessionId to signature on csrf token exchange

* remove ethic modal check and set default settings on new users

* anonymous users can read only + modal on write tries

* refresh session cookie when existing user signin again rather than use the old one

* allow users to keep using the app without loging-in if env var is not present

* typo

* handle denied login

* do not use a form action for login as there is nothing post-ed

* use requiresUser instead of env var to define login modal or not

* move back to a form action for login so user can't be linked to /login directly

* show login modal even for pre-existing users

* fix logic of account creation/updates

* settings insertOne instead of updateOne

* fix missing userId to settings creation

* fix missing updatedAt when updating settings of pre-existing users

* show login modal for everyone + add comments

* fix login modal condition for both required/not required login

* 🔨

* bring back missing form values in login modal

* refactor default settings spread around to a constant

* missing default settings

* typo

* rename a bunch of things to remove SSO references

* always migrate conversations

* remove unneeded sha256 Node specific function, replace with browser crypto API

* fix typings

* Update src/lib/components/LoginModal.svelte

* use authCondition() in callback

* add logout

* 🐛 Fix signout

cc @Grsmto, because "path" of the cookie should be "/"

* fixup! 🐛 Fix signout

* sign out button ui

* add hf logo in the button

---------

Co-authored-by: Eliott C. <coyotte508@gmail.com>
Co-authored-by: Victor Mustar <victor.mustar@gmail.com>

20 files changed +433 -55
Files changed (20)
.env+3-2
package-lock.json+40-3
package.json+2-1
src/app.d.ts+2-2
src/hooks.server.ts+9-17
src/lib/components/EthicsModal.svelte → src/lib/components/LoginModal.svelteRenamed+27-11
src/lib/components/NavMenu.svelte+23-4
src/lib/components/icons/LogoHuggingFaceBorderless.svelteAdded+50
src/lib/server/auth.ts+106-4
src/lib/stores/errors.ts+1
src/lib/types/Settings.ts+7
src/lib/types/User.ts+1-1
src/lib/utils/sha256.ts+2
src/routes/+layout.server.ts+8-3
src/routes/+layout.svelte+5-3
src/routes/conversation/+server.ts+1-1
src/routes/login/+page.server.tsAdded+14
src/routes/login/callback/+server.tsAdded+109
src/routes/logout/+page.server.tsAdded+17
src/routes/settings/+page.server.ts+6-3