mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix: check that application URL and email agent are configured for password reset/generation (#1724)
* fix: check that application URL and email agent are configured for password reset/generation * refactor: reverse flex direction instead of conditionally changing justify
This commit is contained in:
@@ -22,6 +22,7 @@ export interface SettingsAboutResponse {
|
|||||||
export interface PublicSettingsResponse {
|
export interface PublicSettingsResponse {
|
||||||
initialized: boolean;
|
initialized: boolean;
|
||||||
applicationTitle: string;
|
applicationTitle: string;
|
||||||
|
applicationUrl: string;
|
||||||
hideAvailable: boolean;
|
hideAvailable: boolean;
|
||||||
localLogin: boolean;
|
localLogin: boolean;
|
||||||
movie4kEnabled: boolean;
|
movie4kEnabled: boolean;
|
||||||
@@ -33,6 +34,7 @@ export interface PublicSettingsResponse {
|
|||||||
vapidPublic: string;
|
vapidPublic: string;
|
||||||
enablePushRegistration: boolean;
|
enablePushRegistration: boolean;
|
||||||
locale: string;
|
locale: string;
|
||||||
|
emailEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CacheItem {
|
export interface CacheItem {
|
||||||
|
@@ -98,6 +98,7 @@ interface PublicSettings {
|
|||||||
|
|
||||||
interface FullPublicSettings extends PublicSettings {
|
interface FullPublicSettings extends PublicSettings {
|
||||||
applicationTitle: string;
|
applicationTitle: string;
|
||||||
|
applicationUrl: string;
|
||||||
hideAvailable: boolean;
|
hideAvailable: boolean;
|
||||||
localLogin: boolean;
|
localLogin: boolean;
|
||||||
movie4kEnabled: boolean;
|
movie4kEnabled: boolean;
|
||||||
@@ -109,6 +110,7 @@ interface FullPublicSettings extends PublicSettings {
|
|||||||
vapidPublic: string;
|
vapidPublic: string;
|
||||||
enablePushRegistration: boolean;
|
enablePushRegistration: boolean;
|
||||||
locale: string;
|
locale: string;
|
||||||
|
emailEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NotificationAgentConfig {
|
export interface NotificationAgentConfig {
|
||||||
@@ -396,6 +398,7 @@ class Settings {
|
|||||||
return {
|
return {
|
||||||
...this.data.public,
|
...this.data.public,
|
||||||
applicationTitle: this.data.main.applicationTitle,
|
applicationTitle: this.data.main.applicationTitle,
|
||||||
|
applicationUrl: this.data.main.applicationUrl,
|
||||||
hideAvailable: this.data.main.hideAvailable,
|
hideAvailable: this.data.main.hideAvailable,
|
||||||
localLogin: this.data.main.localLogin,
|
localLogin: this.data.main.localLogin,
|
||||||
movie4kEnabled: this.data.radarr.some(
|
movie4kEnabled: this.data.radarr.some(
|
||||||
@@ -411,6 +414,7 @@ class Settings {
|
|||||||
vapidPublic: this.vapidPublic,
|
vapidPublic: this.vapidPublic,
|
||||||
enablePushRegistration: this.data.notifications.agents.webpush.enabled,
|
enablePushRegistration: this.data.notifications.agents.webpush.enabled,
|
||||||
locale: this.data.main.locale,
|
locale: this.data.main.locale,
|
||||||
|
emailEnabled: this.data.notifications.agents.email.enabled,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ import Link from 'next/link';
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
import useSettings from '../../hooks/useSettings';
|
||||||
import Button from '../Common/Button';
|
import Button from '../Common/Button';
|
||||||
import SensitiveInput from '../Common/SensitiveInput';
|
import SensitiveInput from '../Common/SensitiveInput';
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ interface LocalLoginProps {
|
|||||||
|
|
||||||
const LocalLogin: React.FC<LocalLoginProps> = ({ revalidate }) => {
|
const LocalLogin: React.FC<LocalLoginProps> = ({ revalidate }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const settings = useSettings();
|
||||||
const [loginError, setLoginError] = useState<string | null>(null);
|
const [loginError, setLoginError] = useState<string | null>(null);
|
||||||
|
|
||||||
const LoginSchema = Yup.object().shape({
|
const LoginSchema = Yup.object().shape({
|
||||||
@@ -36,6 +38,10 @@ const LocalLogin: React.FC<LocalLoginProps> = ({ revalidate }) => {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const passwordResetEnabled =
|
||||||
|
settings.currentSettings.applicationUrl &&
|
||||||
|
settings.currentSettings.emailEnabled;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
@@ -60,7 +66,7 @@ const LocalLogin: React.FC<LocalLoginProps> = ({ revalidate }) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form>
|
<Form>
|
||||||
<div className="sm:border-t sm:border-gray-800">
|
<div>
|
||||||
<label htmlFor="email" className="text-label">
|
<label htmlFor="email" className="text-label">
|
||||||
{intl.formatMessage(messages.email)}
|
{intl.formatMessage(messages.email)}
|
||||||
</label>
|
</label>
|
||||||
@@ -101,17 +107,7 @@ const LocalLogin: React.FC<LocalLoginProps> = ({ revalidate }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="pt-5 mt-8 border-t border-gray-700">
|
<div className="pt-5 mt-8 border-t border-gray-700">
|
||||||
<div className="flex justify-between">
|
<div className="flex flex-row-reverse justify-between">
|
||||||
<span className="inline-flex rounded-md shadow-sm">
|
|
||||||
<Link href="/resetpassword" passHref>
|
|
||||||
<Button as="a" buttonType="ghost">
|
|
||||||
<SupportIcon />
|
|
||||||
<span>
|
|
||||||
{intl.formatMessage(messages.forgotpassword)}
|
|
||||||
</span>
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
</span>
|
|
||||||
<span className="inline-flex rounded-md shadow-sm">
|
<span className="inline-flex rounded-md shadow-sm">
|
||||||
<Button
|
<Button
|
||||||
buttonType="primary"
|
buttonType="primary"
|
||||||
@@ -126,6 +122,18 @@ const LocalLogin: React.FC<LocalLoginProps> = ({ revalidate }) => {
|
|||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
|
{passwordResetEnabled && (
|
||||||
|
<span className="inline-flex rounded-md shadow-sm">
|
||||||
|
<Link href="/resetpassword" passHref>
|
||||||
|
<Button as="a" buttonType="ghost">
|
||||||
|
<SupportIcon />
|
||||||
|
<span>
|
||||||
|
{intl.formatMessage(messages.forgotpassword)}
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
@@ -94,7 +94,7 @@ const ResetPassword: React.FC = () => {
|
|||||||
{({ errors, touched, isSubmitting, isValid }) => {
|
{({ errors, touched, isSubmitting, isValid }) => {
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<div className="sm:border-t sm:border-gray-800">
|
<div>
|
||||||
<label
|
<label
|
||||||
htmlFor="email"
|
htmlFor="email"
|
||||||
className="block my-1 text-sm font-medium leading-5 text-gray-400 sm:mt-px"
|
className="block my-1 text-sm font-medium leading-5 text-gray-400 sm:mt-px"
|
||||||
|
@@ -108,7 +108,7 @@ const ResetPassword: React.FC = () => {
|
|||||||
{({ errors, touched, isSubmitting, isValid }) => {
|
{({ errors, touched, isSubmitting, isValid }) => {
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<div className="sm:border-t sm:border-gray-800">
|
<div>
|
||||||
<label
|
<label
|
||||||
htmlFor="password"
|
htmlFor="password"
|
||||||
className="block my-1 text-sm font-medium leading-5 text-gray-400 sm:mt-px"
|
className="block my-1 text-sm font-medium leading-5 text-gray-400 sm:mt-px"
|
||||||
|
@@ -3,7 +3,7 @@ import { Field, Form, Formik } from 'formik';
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { useToasts } from 'react-toast-notifications';
|
import { useToasts } from 'react-toast-notifications';
|
||||||
import useSWR from 'swr';
|
import useSWR, { mutate } from 'swr';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import globalMessages from '../../../i18n/globalMessages';
|
import globalMessages from '../../../i18n/globalMessages';
|
||||||
import Badge from '../../Common/Badge';
|
import Badge from '../../Common/Badge';
|
||||||
@@ -159,6 +159,7 @@ const NotificationsEmail: React.FC = () => {
|
|||||||
pgpPassword: values.pgpPassword,
|
pgpPassword: values.pgpPassword,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
mutate('/api/v1/settings/public');
|
||||||
|
|
||||||
addToast(intl.formatMessage(messages.emailsettingssaved), {
|
addToast(intl.formatMessage(messages.emailsettingssaved), {
|
||||||
appearance: 'success',
|
appearance: 'success',
|
||||||
|
@@ -15,7 +15,6 @@ import { useToasts } from 'react-toast-notifications';
|
|||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import type { UserResultsResponse } from '../../../server/interfaces/api/userInterfaces';
|
import type { UserResultsResponse } from '../../../server/interfaces/api/userInterfaces';
|
||||||
import { UserSettingsNotificationsResponse } from '../../../server/interfaces/api/userSettingsInterfaces';
|
|
||||||
import { hasPermission } from '../../../server/lib/permissions';
|
import { hasPermission } from '../../../server/lib/permissions';
|
||||||
import useSettings from '../../hooks/useSettings';
|
import useSettings from '../../hooks/useSettings';
|
||||||
import { useUpdateQueryParams } from '../../hooks/useUpdateQueryParams';
|
import { useUpdateQueryParams } from '../../hooks/useUpdateQueryParams';
|
||||||
@@ -70,7 +69,7 @@ const messages = defineMessages({
|
|||||||
email: 'Email Address',
|
email: 'Email Address',
|
||||||
password: 'Password',
|
password: 'Password',
|
||||||
passwordinfodescription:
|
passwordinfodescription:
|
||||||
'Enable email notifications to allow automatic password generation.',
|
'Configure an application URL and enable email notifications to allow automatic password generation.',
|
||||||
autogeneratepassword: 'Automatically Generate Password',
|
autogeneratepassword: 'Automatically Generate Password',
|
||||||
autogeneratepasswordTip: 'Email a server-generated password to the user',
|
autogeneratepasswordTip: 'Email a server-generated password to the user',
|
||||||
validationEmail: 'You must provide a valid email address',
|
validationEmail: 'You must provide a valid email address',
|
||||||
@@ -102,12 +101,6 @@ const UserList: React.FC = () => {
|
|||||||
pageIndex * currentPageSize
|
pageIndex * currentPageSize
|
||||||
}&sort=${currentSort}`
|
}&sort=${currentSort}`
|
||||||
);
|
);
|
||||||
const { data: notificationSettings } =
|
|
||||||
useSWR<UserSettingsNotificationsResponse>(
|
|
||||||
currentUser
|
|
||||||
? `/api/v1/user/${currentUser?.id}/settings/notifications`
|
|
||||||
: null
|
|
||||||
);
|
|
||||||
|
|
||||||
const [isDeleting, setDeleting] = useState(false);
|
const [isDeleting, setDeleting] = useState(false);
|
||||||
const [isImporting, setImporting] = useState(false);
|
const [isImporting, setImporting] = useState(false);
|
||||||
@@ -254,6 +247,10 @@ const UserList: React.FC = () => {
|
|||||||
const hasNextPage = data.pageInfo.pages > pageIndex + 1;
|
const hasNextPage = data.pageInfo.pages > pageIndex + 1;
|
||||||
const hasPrevPage = pageIndex > 0;
|
const hasPrevPage = pageIndex > 0;
|
||||||
|
|
||||||
|
const passwordGenerationEnabled =
|
||||||
|
settings.currentSettings.applicationUrl &&
|
||||||
|
settings.currentSettings.emailEnabled;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageTitle title={intl.formatMessage(messages.users)} />
|
<PageTitle title={intl.formatMessage(messages.users)} />
|
||||||
@@ -366,12 +363,15 @@ const UserList: React.FC = () => {
|
|||||||
type="warning"
|
type="warning"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!notificationSettings?.emailEnabled && (
|
{currentHasPermission(Permission.MANAGE_SETTINGS) &&
|
||||||
<Alert
|
!passwordGenerationEnabled && (
|
||||||
title={intl.formatMessage(messages.passwordinfodescription)}
|
<Alert
|
||||||
type="info"
|
title={intl.formatMessage(
|
||||||
/>
|
messages.passwordinfodescription
|
||||||
)}
|
)}
|
||||||
|
type="info"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Form className="section">
|
<Form className="section">
|
||||||
<div className="form-row">
|
<div className="form-row">
|
||||||
<label htmlFor="displayName" className="text-label">
|
<label htmlFor="displayName" className="text-label">
|
||||||
@@ -408,7 +408,7 @@ const UserList: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={`form-row ${
|
className={`form-row ${
|
||||||
notificationSettings?.emailEnabled ? '' : 'opacity-50'
|
passwordGenerationEnabled ? '' : 'opacity-50'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<label htmlFor="genpassword" className="checkbox-label">
|
<label htmlFor="genpassword" className="checkbox-label">
|
||||||
@@ -422,7 +422,7 @@ const UserList: React.FC = () => {
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="genpassword"
|
id="genpassword"
|
||||||
name="genpassword"
|
name="genpassword"
|
||||||
disabled={!notificationSettings?.emailEnabled}
|
disabled={!passwordGenerationEnabled}
|
||||||
onClick={() => setFieldValue('password', '')}
|
onClick={() => setFieldValue('password', '')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -9,6 +9,7 @@ export interface SettingsContextProps {
|
|||||||
const defaultSettings = {
|
const defaultSettings = {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
applicationTitle: 'Overseerr',
|
applicationTitle: 'Overseerr',
|
||||||
|
applicationUrl: '',
|
||||||
hideAvailable: false,
|
hideAvailable: false,
|
||||||
localLogin: true,
|
localLogin: true,
|
||||||
movie4kEnabled: false,
|
movie4kEnabled: false,
|
||||||
@@ -20,6 +21,7 @@ const defaultSettings = {
|
|||||||
vapidPublic: '',
|
vapidPublic: '',
|
||||||
enablePushRegistration: false,
|
enablePushRegistration: false,
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
|
emailEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SettingsContext = React.createContext<SettingsContextProps>({
|
export const SettingsContext = React.createContext<SettingsContextProps>({
|
||||||
|
@@ -723,7 +723,7 @@
|
|||||||
"components.UserList.nouserstoimport": "No new users to import from Plex.",
|
"components.UserList.nouserstoimport": "No new users to import from Plex.",
|
||||||
"components.UserList.owner": "Owner",
|
"components.UserList.owner": "Owner",
|
||||||
"components.UserList.password": "Password",
|
"components.UserList.password": "Password",
|
||||||
"components.UserList.passwordinfodescription": "Enable email notifications to allow automatic password generation.",
|
"components.UserList.passwordinfodescription": "Configure an application URL and enable email notifications to allow automatic password generation.",
|
||||||
"components.UserList.plexuser": "Plex User",
|
"components.UserList.plexuser": "Plex User",
|
||||||
"components.UserList.role": "Role",
|
"components.UserList.role": "Role",
|
||||||
"components.UserList.sortCreated": "Creation Date",
|
"components.UserList.sortCreated": "Creation Date",
|
||||||
|
@@ -148,6 +148,7 @@ CoreApp.getInitialProps = async (initialProps) => {
|
|||||||
let currentSettings: PublicSettingsResponse = {
|
let currentSettings: PublicSettingsResponse = {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
applicationTitle: '',
|
applicationTitle: '',
|
||||||
|
applicationUrl: '',
|
||||||
hideAvailable: false,
|
hideAvailable: false,
|
||||||
movie4kEnabled: false,
|
movie4kEnabled: false,
|
||||||
series4kEnabled: false,
|
series4kEnabled: false,
|
||||||
@@ -159,6 +160,7 @@ CoreApp.getInitialProps = async (initialProps) => {
|
|||||||
vapidPublic: '',
|
vapidPublic: '',
|
||||||
enablePushRegistration: false,
|
enablePushRegistration: false,
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
|
emailEnabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ctx.res) {
|
if (ctx.res) {
|
||||||
|
Reference in New Issue
Block a user