👥 fix: Reinstate Default Social Login Values (#1811)

* fix: social logins accidentally removed default in AppService, reinstated and added test

* chore: move birthday to OTHER section and make disabled by default
This commit is contained in:
Danny Avila 2024-02-15 08:20:06 -05:00 committed by GitHub
parent 60b1d1332c
commit 637a1a41c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 25 additions and 14 deletions

View file

@ -26,8 +26,6 @@ DOMAIN_SERVER=http://localhost:3080
NO_INDEX=true
SHOW_BIRTHDAY_ICON=true
#===============#
# Debug Logging #
#===============#
@ -325,8 +323,15 @@ FIREBASE_APP_ID=
# NODE_ENV=
# If using Redis, you should flush the cache after changing any LibreChat settings
# REDIS_URI=
# USE_REDIS=
# Give the AI Icon a Birthday Hat :)
# Will show automatically on February 11th (LibreChat's birthday)
# Set this to false to disable the birthday hat
# Set to true to enable all the time.
# SHOW_BIRTHDAY_ICON=true
# E2E_USER_EMAIL=
# E2E_USER_PASSWORD=

View file

@ -11,6 +11,7 @@ const configureSocialLogins = require('./socialLogins');
const { connectDb, indexSync } = require('~/lib/db');
const AppService = require('./services/AppService');
const noIndex = require('./middleware/noIndex');
const { isEnabled } = require('~/server/utils');
const { logger } = require('~/config');
const routes = require('./routes');
@ -53,7 +54,7 @@ const startServer = async () => {
passport.use(await jwtLogin());
passport.use(passportLogin());
if (ALLOW_SOCIAL_LOGIN?.toLowerCase() === 'true') {
if (isEnabled(ALLOW_SOCIAL_LOGIN)) {
configureSocialLogins(app);
}

View file

@ -1,4 +1,5 @@
const express = require('express');
const { defaultSocialLogins } = require('librechat-data-provider');
const { isEnabled } = require('~/server/utils');
const { logger } = require('~/config');
@ -15,7 +16,7 @@ router.get('/', async function (req, res) {
try {
const payload = {
appTitle: process.env.APP_TITLE || 'LibreChat',
socialLogins: req.app.locals.socialLogins,
socialLogins: req.app.locals.socialLogins ?? defaultSocialLogins,
discordLoginEnabled: !!process.env.DISCORD_CLIENT_ID && !!process.env.DISCORD_CLIENT_SECRET,
facebookLoginEnabled:
!!process.env.FACEBOOK_CLIENT_ID && !!process.env.FACEBOOK_CLIENT_SECRET,

View file

@ -1,4 +1,9 @@
const { FileSources, EModelEndpoint, Constants } = require('librechat-data-provider');
const {
FileSources,
EModelEndpoint,
Constants,
defaultSocialLogins,
} = require('librechat-data-provider');
const { initializeFirebase } = require('./Files/Firebase/initialize');
const loadCustomConfig = require('./Config/loadCustomConfig');
const handleRateLimits = require('./Config/handleRateLimits');
@ -35,10 +40,13 @@ const AppService = async (app) => {
]),
});
const socialLogins = config?.registration?.socialLogins ?? defaultSocialLogins;
if (!Object.keys(config).length) {
app.locals = {
availableTools,
fileStrategy,
socialLogins,
paths,
};
@ -52,13 +60,6 @@ const AppService = async (app) => {
}
handleRateLimits(config?.rateLimits);
const socialLogins = config?.registration?.socialLogins ?? [
'google',
'facebook',
'openid',
'github',
'discord',
];
const endpointLocals = {};
if (config?.endpoints?.[EModelEndpoint.assistants]) {

View file

@ -1,4 +1,4 @@
const { FileSources } = require('librechat-data-provider');
const { FileSources, defaultSocialLogins } = require('librechat-data-provider');
const AppService = require('./AppService');
@ -240,6 +240,7 @@ describe('AppService updating app.locals', () => {
expect(app.locals.paths).toBeDefined();
expect(app.locals.availableTools).toBeDefined();
expect(app.locals.fileStrategy).toEqual(FileSources.local);
expect(app.locals.socialLogins).toEqual(defaultSocialLogins);
});
it('should update app.locals with values from loadCustomConfig', async () => {

View file

@ -4,6 +4,8 @@ import { EModelEndpoint, eModelEndpointSchema } from './schemas';
import { fileConfigSchema } from './file-config';
import { FileSources } from './types/files';
export const defaultSocialLogins = ['google', 'facebook', 'openid', 'github', 'discord'];
export const fileSourceSchema = z.nativeEnum(FileSources);
export const assistantEndpointSchema = z.object({