fix(ui/notif): Custom application title in password-related emails and UI messages (#979)

pull/981/head
TheCatLady 4 years ago committed by GitHub
parent c700aa938f
commit 4e2706b421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -134,7 +134,7 @@ export class User {
const password = generatePassword.randomPassword({ length: 16 });
this.setPassword(password);
const applicationUrl = getSettings().main.applicationUrl;
const { applicationTitle, applicationUrl } = getSettings().main;
try {
logger.info(`Sending generated password email for ${this.email}`, {
label: 'User Management',
@ -148,6 +148,7 @@ export class User {
locals: {
password: password,
applicationUrl,
applicationTitle,
},
});
} catch (e) {
@ -167,7 +168,7 @@ export class User {
targetDate.setDate(targetDate.getDate() + 1);
this.recoveryLinkExpirationDate = targetDate;
const applicationUrl = getSettings().main.applicationUrl;
const { applicationTitle, applicationUrl } = getSettings().main;
const resetPasswordLink = `${applicationUrl}/resetpassword/${guid}`;
try {
@ -183,6 +184,7 @@ export class User {
locals: {
resetPasswordLink,
applicationUrl: resetPasswordLink,
applicationTitle,
},
});
} catch (e) {

@ -11,6 +11,7 @@ import Alert from '../../../Common/Alert';
import Button from '../../../Common/Button';
import LoadingSpinner from '../../../Common/LoadingSpinner';
import * as Yup from 'yup';
import useSettings from '../../../../hooks/useSettings';
const messages = defineMessages({
password: 'Password',
@ -30,10 +31,12 @@ const messages = defineMessages({
validationConfirmPasswordSame: 'Password must match',
nopasswordset: 'No Password Set',
nopasswordsetDescription:
'This user account currently does not have an Overseerr-specific password. Configure a password below to allow this account to sign-in as a "local user."',
'This user account currently does not have a password specifically for {applicationTitle}.\
Configure a password below to enable this account to sign in as a "local user."',
});
const UserPasswordChange: React.FC = () => {
const settings = useSettings();
const intl = useIntl();
const { addToast } = useToasts();
const router = useRouter();
@ -114,7 +117,9 @@ const UserPasswordChange: React.FC = () => {
type="warning"
title={intl.formatMessage(messages.nopasswordset)}
>
{intl.formatMessage(messages.nopasswordsetDescription)}
{intl.formatMessage(messages.nopasswordsetDescription, {
applicationTitle: settings.currentSettings.applicationTitle,
})}
</Alert>
)}
{data.hasPassword && user?.id === currentUser?.id && (

@ -7,6 +7,7 @@ import Error from '../../../pages/_error';
import LoadingSpinner from '../../Common/LoadingSpinner';
import PageTitle from '../../Common/PageTitle';
import ProfileHeader from '../ProfileHeader';
import useSettings from '../../../hooks/useSettings';
const messages = defineMessages({
settings: 'User Settings',
@ -26,6 +27,7 @@ interface SettingsRoute {
const UserSettings: React.FC = ({ children }) => {
const router = useRouter();
const settings = useSettings();
const { hasPermission } = useUser();
const { user, error } = useUser({ id: Number(router.query.userId) });
const intl = useIntl();
@ -73,6 +75,14 @@ const UserSettings: React.FC = ({ children }) => {
regex: RegExp;
isMobile?: boolean;
}> = ({ children, route, regex, isMobile = false }) => {
if (
route === '/settings/password' &&
!settings.currentSettings.localLogin &&
!hasPermission(Permission.MANAGE_SETTINGS)
) {
return null;
}
const finalRoute = router.asPath.includes('/profile')
? `/profile${route}`
: `/users/${user.id}${route}`;

@ -647,7 +647,7 @@
"components.UserList.role": "Role",
"components.UserList.save": "Save Changes",
"components.UserList.saving": "Saving…",
"components.UserList.showingResults": "Showing <strong>{from}</strong> to <strong>{to}</strong> of <strong>{total}</strong> results",
"components.UserList.showingresults": "Showing <strong>{from}</strong> to <strong>{to}</strong> of <strong>{total}</strong> results",
"components.UserList.sortCreated": "Creation Date",
"components.UserList.sortDisplayName": "Display Name",
"components.UserList.sortRequests": "Request Count",
@ -690,7 +690,7 @@
"components.UserProfile.UserSettings.UserPasswordChange.currentpassword": "Current Password",
"components.UserProfile.UserSettings.UserPasswordChange.newpassword": "New Password",
"components.UserProfile.UserSettings.UserPasswordChange.nopasswordset": "No Password Set",
"components.UserProfile.UserSettings.UserPasswordChange.nopasswordsetDescription": "This user account currently does not have an Overseerr-specific password. Configure a password below to allow this account to sign-in as a \"local user.\"",
"components.UserProfile.UserSettings.UserPasswordChange.nopasswordsetDescription": "This user account currently does not have a password specifically for {applicationTitle}. Configure a password below to enable this account to sign in as a \"local user.\"",
"components.UserProfile.UserSettings.UserPasswordChange.password": "Password",
"components.UserProfile.UserSettings.UserPasswordChange.save": "Save Changes",
"components.UserProfile.UserSettings.UserPasswordChange.saving": "Saving…",

Loading…
Cancel
Save