Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from next-auth to supabase-auth (On refactored code) #105

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from

Conversation

daniel-farina
Copy link
Collaborator

@daniel-farina daniel-farina commented Nov 24, 2023

This PR moves this project away from next-auth to supabase-auth. This makes the configuration a lot simpler.

Tasks:

Now the application works immediately once supabase is configured, you can login with magic links, no need to setup smtp providers.

Todo

The login by wildcard *@email feature has been removed, we might want to add that again

Changes to be committed:
	modified:   apps/unsaged/.env.local.example
	deleted:    apps/unsaged/app/api/auth/[...nextauth]/route.ts
	new file:   apps/unsaged/app/api/auth/route.ts
	modified:   apps/unsaged/app/api/models/route.ts
	new file:   apps/unsaged/app/auth/callback/route.ts
	new file:   apps/unsaged/app/auth/signin/auth-form.tsx
	new file:   apps/unsaged/app/auth/signin/page.tsx
	new file:   apps/unsaged/app/auth/signout/route.ts
	modified:   apps/unsaged/components/Home/components/PrimaryMenu/components/ActivityBar/ActivityBar.tsx
	modified:   apps/unsaged/components/Home/components/SecondaryMenu/components/Menu/components/Screens/ModelSettings/components/model.tsx
	modified:   apps/unsaged/db/GenerationScript.sql
	modified:   apps/unsaged/middleware.ts
	modified:   apps/unsaged/package.json
	deleted:    apps/unsaged/types/auth-provider.ts
	deleted:    apps/unsaged/types/next-auth.d.ts
	new file:   apps/unsaged/types/supabase.types.ts
	modified:   apps/unsaged/utils/app/auth/helpers.ts
	deleted:    apps/unsaged/utils/app/auth/providers.ts
	modified:   apps/unsaged/utils/app/const.ts
	modified:   apps/unsaged/utils/app/storage/supabase/helpers/conversations.ts
	modified:   apps/unsaged/utils/server/ai_vendors/openai/models.ts
	modified:   pnpm-lock.yaml
Copy link

vercel bot commented Nov 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unsaged ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 24, 2023 9:24pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unsaged-docs ⬜️ Ignored (Inspect) Visit Preview Nov 24, 2023 9:24pm

@sebiweise
Copy link
Collaborator

sebiweise commented Nov 24, 2023

@daniel-farina Just one quick thought:
Wouldn´t it be easier to just check if the specific AI Vendor Key is defined? Something like

if(openai_key || OPENAI_API_KEY) {
  const response = await getAvailableOpenAIModels(openai_key);
  ...
}

This way we don´t need to add another configuration variable to unsaged.

I honestly don´t see the point of the ability to disable AI vendors via ENV var, either you don´t define a Global API Key and/or Url settings or the user don´t define a key in the frontend so I think disabling the model lookup by the existence of the necessary configuration would be enough, what do you mean?

@daniel-farina
Copy link
Collaborator Author

@daniel-farina Just one quick thought: Wouldn´t it be easier to just check if the specific AI Vendor Key is defined? Something like

if(openai_key || OPENAI_API_KEY) {
  const response = await getAvailableOpenAIModels(openai_key);
  ...
}

This way we don´t need to add another configuration variable to unsaged.

I honestly don´t see the point of the ability to disable AI vendors via ENV var, either you don´t define a Global API Key and/or Url settings or the user don´t define a key in the frontend so I think disabling the model lookup by the existence of the necessary configuration would be enough, what do you mean?

I initially had the same thought, but then I realized that it's not foolproof. If someone merely uses a placeholder, they might not be aware that it's active, even if the key is incorrect. Therefore the app consistently attempt to fetch the models with wrong keys.

but actually I'm ok with if(openai_key || OPENAI_API_KEY) and just explaining tha adding a value will automatically activate fetching of models on the app as a note on the docs.

@sebiweise
Copy link
Collaborator

That's a point but I think everyone who is hosting undated themself will know that he has to put a valid key in it, for the user input we could implement a simple validation of a minimum length or something like that. I don't know maybe there is a regex for the validation of OpenAI API key?

@daniel-farina
Copy link
Collaborator Author

That's a point but I think everyone who is hosting undated themself will know that he has to put a valid key in it, for the user input we could implement a simple validation of a minimum length or something like that. I don't know maybe there is a regex for the validation of OpenAI API key?

works with me! 👍 I'll change it before we merge. I'm still troubleshooting SSR and latest version of supabase. Checkout the last commit, it should be working now. I'm just troubleshooting prod buildon vercel. Prod build works on local env for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants