Skip to content

Commit

Permalink
Merge pull request fedimint#252 from Kodylow/confirm-password
Browse files Browse the repository at this point in the history
feat: confirm password field
  • Loading branch information
wbobeirne committed Nov 1, 2023
2 parents 64b7c25 + 60985fa commit 58a4970
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
18 changes: 18 additions & 0 deletions apps/guardian-ui/src/components/SetConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Button,
Text,
useTheme,
FormErrorMessage,
} from '@chakra-ui/react';
import { useTranslation } from '@fedimint/utils';
import { FormGroup, FormGroupHeading } from '@fedimint/ui';
Expand Down Expand Up @@ -51,6 +52,7 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
const isHost = role === GuardianRole.Host;
const [myName, setMyName] = useState(stateMyName);
const [password, setPassword] = useState(statePassword);
const [confirmPassword, setConfirmPassword] = useState('');
const [hostServerUrl, setHostServerUrl] = useState('');
const [defaultParams, setDefaultParams] = useState<ConfigGenParams>();
const [numPeers, setNumPeers] = useState(
Expand Down Expand Up @@ -114,6 +116,7 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
? Boolean(
myName &&
password &&
password === confirmPassword &&
federationName &&
isValidNumber(numPeers, 4) &&
isValidNumber(blockConfirmations, 1, 200) &&
Expand Down Expand Up @@ -215,6 +218,21 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
/>
<FormHelperText>{t('set-config.admin-password-help')}</FormHelperText>
</FormControl>
<FormControl
isInvalid={password !== confirmPassword && password.length > 0}
>
<FormLabel>{t('set-config.confirm-password')}</FormLabel>
<Input
type='password'
value={confirmPassword}
onChange={(ev) => setConfirmPassword(ev.currentTarget.value)}
/>
<FormErrorMessage>
{password !== confirmPassword &&
password.length > 0 &&
t('set-config.error-password-mismatch')}
</FormErrorMessage>
</FormControl>
{!isHost && (
<FormControl>
<FormLabel>{t('set-config.join-federation')}</FormLabel>
Expand Down
5 changes: 4 additions & 1 deletion apps/guardian-ui/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"guardian-name-help": "This name will be shown to other Guardians",
"admin-password": "Admin password",
"admin-password-help": "You'll need this every time you visit this page.",
"confirm-password": "Confirm password",
"confirm-password-help": "You'll need this every time you visit this page.",
"error-password-mismatch": "Passwords don't match",
"join-federation": "Join Federation link",
"join-federation-help": "Ask the person who created the Federation for a link, and paste it here.",
"federation-settings": "Federation settings",
Expand All @@ -100,7 +103,7 @@
"error-valid-max": "Please input a number of at most {{max}}.",
"error-valid-min-max": "Please input a number between {{min}} and {{max}}.",
"meta-fields": "Meta fields",
"meta-fields-description": "Additional configuration sent to fedimint clients. See <docs>documentation</docs> or more information.",
"meta-fields-description": "Additional configuration sent to fedimint clients. See <docs>documentation</docs> for more information.",
"meta-fields-key": "Meta key",
"meta-fields-value": "Value",
"meta-fields-add-another": "Add another"
Expand Down
3 changes: 3 additions & 0 deletions apps/guardian-ui/src/languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
"set-config": {
"admin-password": "Contraseña de administrador",
"admin-password-help": "Necesitarás esto cada vez que visites esta página.",
"confirm-password": "Confirmar contraseña",
"confirm-password-help": "Necesitarás esto cada vez que visites esta página",
"error-password-mismatch": "Las contraseñas no coinciden",
"bitcoin-network": "Red de Bitcoin",
"bitcoin-rpc": "RPC de Bitcoin",
"block-confirmations": "Confirmaciones de bloque",
Expand Down
3 changes: 3 additions & 0 deletions apps/guardian-ui/src/languages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
"set-config": {
"admin-password": "관리자 비밀번호",
"admin-password-help": "매번 페이지를 방문할 때마다 필요합니다.",
"confirm-password": "비밀번호 확인",
"confirm-password-help": "이 페이지를 방문할 때마다 이 정보가 필요합니다.",
"error-password-mismatch": "비밀번호가 일치하지 않습니다",
"bitcoin-network": "비트코인 네트워크",
"bitcoin-rpc": "비트코인 RPC",
"block-confirmations": "블록 확인",
Expand Down

0 comments on commit 58a4970

Please sign in to comment.