📧 feat: disable login (ALLOW_EMAIL_LOGIN) (#1282)

* added ALLOW_EMAIL_LOGIN

* update .env.example

* fix(config) email login true by default

* Update dotenv.md
This commit is contained in:
Marco Beretta 2023-12-06 13:08:49 +01:00 committed by GitHub
parent 1706886a64
commit fdb65366d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 3 deletions

View file

@ -214,6 +214,7 @@ CHECK_BALANCE=false
# Registration and Login #
#========================#
ALLOW_EMAIL_LOGIN=true
ALLOW_REGISTRATION=true
ALLOW_SOCIAL_LOGIN=false
ALLOW_SOCIAL_REGISTRATION=false

View file

@ -62,6 +62,7 @@ describe.skip('GET /', () => {
githubLoginEnabled: true,
discordLoginEnabled: true,
serverDomain: 'http://test-server.com',
emailLoginEnabled: 'true',
registrationEnabled: 'true',
socialLoginEnabled: 'true',
});

View file

@ -1,6 +1,8 @@
const express = require('express');
const router = express.Router();
const { isEnabled } = require('../utils');
const emailLoginEnabled =
process.env.ALLOW_EMAIL_LOGIN === undefined || isEnabled(process.env.ALLOW_EMAIL_LOGIN);
router.get('/', async function (req, res) {
try {
@ -19,6 +21,7 @@ router.get('/', async function (req, res) {
githubLoginEnabled: !!process.env.GITHUB_CLIENT_ID && !!process.env.GITHUB_CLIENT_SECRET,
discordLoginEnabled: !!process.env.DISCORD_CLIENT_ID && !!process.env.DISCORD_CLIENT_SECRET,
serverDomain: process.env.DOMAIN_SERVER || 'http://localhost:3080',
emailLoginEnabled,
registrationEnabled: isEnabled(process.env.ALLOW_REGISTRATION),
socialLoginEnabled: isEnabled(process.env.ALLOW_SOCIAL_LOGIN),
emailEnabled:

View file

@ -34,7 +34,7 @@ function Login() {
{localize(getLoginError(error))}
</div>
)}
<LoginForm onSubmit={login} />
{startupConfig?.emailLoginEnabled && <LoginForm onSubmit={login} />}
{startupConfig?.registrationEnabled && (
<p className="my-4 text-center text-sm font-light text-gray-700">
{' '}
@ -44,7 +44,7 @@ function Login() {
</a>
</p>
)}
{startupConfig?.socialLoginEnabled && (
{startupConfig?.socialLoginEnabled && startupConfig?.emailLoginEnabled && (
<>
<div className="relative mt-6 flex w-full items-center justify-center border border-t uppercase">
<div className="absolute bg-white px-3 text-xs">Or</div>

View file

@ -39,6 +39,7 @@ const setup = ({
githubLoginEnabled: true,
discordLoginEnabled: true,
registrationEnabled: true,
emailLoginEnabled: true,
socialLoginEnabled: true,
serverDomain: 'mock-server',
},

View file

@ -39,6 +39,7 @@ const setup = ({
openidImageUrl: 'http://test-server.com',
githubLoginEnabled: true,
discordLoginEnabled: true,
emailLoginEnabled: true,
registrationEnabled: true,
socialLoginEnabled: true,
serverDomain: 'mock-server',

View file

@ -507,7 +507,10 @@ CHECK_BALANCE=false
### Registration and Login
see: [User/Auth System](../install/user_auth_system.md)
![image](https://github.com/danny-avila/LibreChat/assets/81851188/52a37d1d-7392-4a9a-a79f-90ed2da7f841)
- General Settings:
- `ALLOW_EMAIL_LOGIN`: Email login. Set to `true` or `false` to enable or disable ONLY email login.
- `ALLOW_REGISTRATION`: Email registration of new users. Set to `true` or `false` to enable or disable Email registration.
- `ALLOW_SOCIAL_LOGIN`: Allow users to connect to LibreChat with various social networks, see below. Set to `true` or `false` to enable or disable.
- `ALLOW_SOCIAL_REGISTRATION`: Enable or disable registration of new user using various social network. Set to `true` or `false` to enable or disable.
@ -668,4 +671,4 @@ Mail address for from field. It is **REQUIRED** to set a value here (even if it'
```bash
EMAIL_FROM=noreply@librechat.ai
```
```

View file

@ -178,6 +178,7 @@ export type TStartupConfig = {
openidImageUrl: string;
discordLoginEnabled: boolean;
serverDomain: string;
emailLoginEnabled: boolean;
registrationEnabled: boolean;
socialLoginEnabled: boolean;
emailEnabled: boolean;