From 8c46eada4be16fee3c7d6b5ec2786b3d9b214b00 Mon Sep 17 00:00:00 2001 From: Wang Sijie Date: Tue, 28 Jun 2022 17:41:06 +0800 Subject: [PATCH] feat(console): reset user password (#1266) --- .../UserDetails/components/CreateSuccess.tsx | 21 +++---- .../components/ResetPasswordForm.tsx | 55 ++++++------------- .../console/src/pages/UserDetails/index.tsx | 33 ++++++++++- packages/phrases/src/locales/en.ts | 6 +- packages/phrases/src/locales/zh-cn.ts | 6 +- 5 files changed, 60 insertions(+), 61 deletions(-) diff --git a/packages/console/src/pages/UserDetails/components/CreateSuccess.tsx b/packages/console/src/pages/UserDetails/components/CreateSuccess.tsx index e551caf0d..8cd2165be 100644 --- a/packages/console/src/pages/UserDetails/components/CreateSuccess.tsx +++ b/packages/console/src/pages/UserDetails/components/CreateSuccess.tsx @@ -1,8 +1,8 @@ +import { AdminConsoleKey } from '@logto/phrases'; import React, { useState } from 'react'; import { toast } from 'react-hot-toast'; import { useTranslation } from 'react-i18next'; import ReactModal from 'react-modal'; -import { useSearchParams } from 'react-router-dom'; import Button from '@/components/Button'; import IconButton from '@/components/IconButton'; @@ -14,19 +14,14 @@ import * as styles from './CreateSuccess.module.scss'; type Props = { username: string; + password: string; + title: AdminConsoleKey; + onClose: () => void; }; -const CreateSuccess = ({ username }: Props) => { - const [searchParameters, setSearchParameters] = useSearchParams(); - const [passwordVisible, setPasswordVisible] = useState(false); +const CreateSuccess = ({ username, password, title, onClose }: Props) => { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); - - const passwordEncoded = searchParameters.get('password'); - const password = passwordEncoded && atob(passwordEncoded); - - const handleClose = () => { - setSearchParameters({}); - }; + const [passwordVisible, setPasswordVisible] = useState(false); const handleCopy = async () => { if (!password) { @@ -45,10 +40,10 @@ const CreateSuccess = ({ username }: Props) => { return ( -