mirror of
https://github.com/outline/outline.git
synced 2026-11-28 08:14:58 +03:00
Add option for admin to trigger email change
This commit is contained in:
1 parent
97ff6baf02
commit
dfb266cc73
3 files changed
+45
-7
No files matched your search
@@ -5,6 +5,7 @@ import { UserRole } from "@shared/types";
|
||||
import User from "~/models/User";
|
||||
import ConfirmationDialog from "~/components/ConfirmationDialog";
|
||||
import Input from "~/components/Input";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import { client } from "~/utils/ApiClient";
|
||||
import Text from "./Text";
|
||||
@@ -135,6 +136,7 @@ export function UserChangeNameDialog({ user, onSubmit }: Props) {
|
||||
|
||||
export function UserChangeEmailDialog({ user, onSubmit }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const actor = useCurrentUser();
|
||||
const [email, setEmail] = React.useState<string>(user.email);
|
||||
const [error, setError] = React.useState<string | undefined>();
|
||||
|
||||
@@ -142,7 +144,11 @@ export function UserChangeEmailDialog({ user, onSubmit }: Props) {
|
||||
try {
|
||||
await client.post(`/users.updateEmail`, { id: user.id, email });
|
||||
onSubmit();
|
||||
toast.info(t("Check your email to verify the new address."));
|
||||
toast.info(
|
||||
actor.id === user.id
|
||||
? t("Check your email to verify the new address.")
|
||||
: t("The email will be changed once verified.")
|
||||
);
|
||||
return true;
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
@@ -162,10 +168,17 @@ export function UserChangeEmailDialog({ user, onSubmit }: Props) {
|
||||
disabled={!email || email === user.email}
|
||||
>
|
||||
<Text as="p">
|
||||
<Trans>
|
||||
You will receive an email to verify your new address. It must be
|
||||
unique in the workspace.
|
||||
</Trans>
|
||||
{actor.id === user.id ? (
|
||||
<Trans>
|
||||
You will receive an email to verify your new address. It must be
|
||||
unique in the workspace.
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans>
|
||||
A confirmation email will be sent to the new address before it is
|
||||
changed.
|
||||
</Trans>
|
||||
)}
|
||||
</Text>
|
||||
<Input
|
||||
type="email"
|
||||
|
||||
+24
-1
@@ -11,6 +11,7 @@ import Template from "~/components/ContextMenu/Template";
|
||||
import {
|
||||
UserSuspendDialog,
|
||||
UserChangeNameDialog,
|
||||
UserChangeEmailDialog,
|
||||
} from "~/components/UserDialogs";
|
||||
import { actionToMenuItem } from "~/actions";
|
||||
import {
|
||||
@@ -49,6 +50,22 @@ function UserMenu({ user }: Props) {
|
||||
[dialogs, t, user]
|
||||
);
|
||||
|
||||
const handleChangeEmail = React.useCallback(
|
||||
(ev: React.SyntheticEvent) => {
|
||||
ev.preventDefault();
|
||||
dialogs.openModal({
|
||||
title: t("Change email"),
|
||||
content: (
|
||||
<UserChangeEmailDialog
|
||||
user={user}
|
||||
onSubmit={dialogs.closeAllModals}
|
||||
/>
|
||||
),
|
||||
});
|
||||
},
|
||||
[dialogs, t, user]
|
||||
);
|
||||
|
||||
const handleSuspend = React.useCallback(
|
||||
(ev: React.SyntheticEvent) => {
|
||||
ev.preventDefault();
|
||||
@@ -117,7 +134,13 @@ function UserMenu({ user }: Props) {
|
||||
type: "button",
|
||||
title: `${t("Change name")}…`,
|
||||
onClick: handleChangeName,
|
||||
visible: can.update && user.role !== "admin",
|
||||
visible: can.update,
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
title: `${t("Change email")}…`,
|
||||
onClick: handleChangeEmail,
|
||||
visible: can.update,
|
||||
},
|
||||
{
|
||||
type: "button",
|
||||
|
||||
@@ -403,7 +403,9 @@
|
||||
"New name": "New name",
|
||||
"Name can't be empty": "Name can't be empty",
|
||||
"Check your email to verify the new address.": "Check your email to verify the new address.",
|
||||
"The email will be changed once verified.": "The email will be changed once verified.",
|
||||
"You will receive an email to verify your new address. It must be unique in the workspace.": "You will receive an email to verify your new address. It must be unique in the workspace.",
|
||||
"A confirmation email will be sent to the new address before it is changed.": "A confirmation email will be sent to the new address before it is changed.",
|
||||
"New email": "New email",
|
||||
"Email can't be empty": "Email can't be empty",
|
||||
"Your import completed": "Your import completed",
|
||||
@@ -547,6 +549,7 @@
|
||||
"Headings you add to the document will appear here": "Headings you add to the document will appear here",
|
||||
"Table of contents": "Table of contents",
|
||||
"Change name": "Change name",
|
||||
"Change email": "Change email",
|
||||
"Suspend user": "Suspend user",
|
||||
"An error occurred while sending the invite": "An error occurred while sending the invite",
|
||||
"User options": "User options",
|
||||
@@ -982,7 +985,6 @@
|
||||
"Auto-format text by replacing shortcuts with symbols, dashes, smart quotes, and other typographical elements.": "Auto-format text by replacing shortcuts with symbols, dashes, smart quotes, and other typographical elements.",
|
||||
"You may delete your account at any time, note that this is unrecoverable": "You may delete your account at any time, note that this is unrecoverable",
|
||||
"Profile saved": "Profile saved",
|
||||
"Change email": "Change email",
|
||||
"Profile picture updated": "Profile picture updated",
|
||||
"Unable to upload new profile picture": "Unable to upload new profile picture",
|
||||
"Manage how you appear to other members of the workspace.": "Manage how you appear to other members of the workspace.",
|
||||
|
||||
Reference in new issue
Block a user