feat(ui): Add local login setting (#817)

This commit is contained in:
TheCatLady
2021-02-02 20:16:44 -05:00
committed by GitHub
parent b576f0734f
commit 9d0d5b86aa
11 changed files with 68 additions and 22 deletions

View File

@@ -10,6 +10,7 @@ export interface PublicSettingsResponse {
movie4kEnabled: boolean;
series4kEnabled: boolean;
hideAvailable: boolean;
localLogin: boolean;
}
export interface CacheItem {

View File

@@ -54,6 +54,7 @@ export interface MainSettings {
csrfProtection: boolean;
defaultPermissions: number;
hideAvailable: boolean;
localLogin: boolean;
trustProxy: boolean;
}
@@ -65,6 +66,7 @@ interface FullPublicSettings extends PublicSettings {
movie4kEnabled: boolean;
series4kEnabled: boolean;
hideAvailable: boolean;
localLogin: boolean;
}
export interface NotificationAgentConfig {
@@ -162,6 +164,7 @@ class Settings {
csrfProtection: false,
defaultPermissions: Permission.REQUEST,
hideAvailable: false,
localLogin: true,
trustProxy: false,
},
plex: {
@@ -296,6 +299,7 @@ class Settings {
(sonarr) => sonarr.is4k && sonarr.isDefault
),
hideAvailable: this.data.main.hideAvailable,
localLogin: this.data.main.localLogin,
};
}

View File

@@ -134,10 +134,13 @@ authRoutes.post('/login', async (req, res, next) => {
});
authRoutes.post('/local', async (req, res, next) => {
const settings = getSettings();
const userRepository = getRepository(User);
const body = req.body as { email?: string; password?: string };
if (!body.email || !body.password) {
if (!settings.main.localLogin) {
return res.status(500).json({ error: 'Local user login is disabled' });
} else if (!body.email || !body.password) {
return res
.status(500)
.json({ error: 'You must provide an email and a password' });