Skip to content

Commit 9c3c628

Browse files
committed
Hide passwords
1 parent 8932a4e commit 9c3c628

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

frontend/src/components/auth/LoginForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function LoginForm() {
5757

5858
<FormControl id='password' isRequired>
5959
<FormLabel>Password</FormLabel>
60-
<Input type='text'
60+
<Input type='password'
6161
name="password"
6262
value={password}
6363
onChange={(e) => { setPassword(e.target.value) }}

frontend/src/components/auth/ResgistrationForm.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@ import { AxiosError } from 'axios';
1919
export default function RegistrationForm() {
2020
const [username, setUsername] = useState('');
2121
const [password, setPassword] = useState('');
22+
const [rePassword, setRePassword] = useState('');
2223
const dispatch = useDispatch()
2324
const navigate = useNavigate()
2425
const toast = useToast();
2526

2627

28+
const ensureSamePassword = (password: string, rePassword: string) => {
29+
if (password !== rePassword) {
30+
throw Error('Make sure you re-type your new password correctly!')
31+
}
32+
}
33+
2734
const ensureStrongPassword = (password: string) => {
2835
if (password.length < 8) {
2936
throw Error('Password must be 8 characters or more!')
@@ -34,7 +41,9 @@ export default function RegistrationForm() {
3441
const onSubmit = async (e: any) => {
3542
e.preventDefault();
3643
try {
44+
ensureSamePassword(password.trim(), rePassword.trim());
3745
ensureStrongPassword(password.trim());
46+
3847
const response = await register(username.trim(), password.trim());
3948
const user = response.data.user;
4049

@@ -78,13 +87,23 @@ export default function RegistrationForm() {
7887

7988
<FormControl id='password' isRequired>
8089
<FormLabel>Password</FormLabel>
81-
<Input type='text'
90+
<Input type='password'
8291
name="password"
8392
value={password}
8493
onChange={(e) => { setPassword(e.target.value) }}
8594
/>
8695
</FormControl>
8796

97+
<FormControl id='repassword' isRequired>
98+
<FormLabel>Re-type Password</FormLabel>
99+
<Input type='password'
100+
name="repassword"
101+
value={rePassword}
102+
onChange={(e) => { setRePassword(e.target.value) }}
103+
/>
104+
</FormControl>
105+
106+
88107
<HStack>
89108

90109
<Button colorScheme="blue" type="submit">

frontend/src/components/profile_page/ChangePasswordCard/ChangePasswordCard.component.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ export default function ChangePasswordCard() {
5151
<FormControl id='newPassword'>
5252
<FormLabel>New Password</FormLabel>
5353
<Input type='text'
54-
name="newPassword"
54+
name="password"
5555
value={newPassword}
5656
onChange={(e) => { setNewPassword(e.target.value) }}
5757
/>
5858
</FormControl>
5959
<FormControl id='retypePassword'>
6060
<FormLabel>Re-type Password</FormLabel>
61-
<Input type='text'
61+
<Input type='password'
6262
name="retypePassword"
6363
value={retypePassword}
6464
onChange={(e) => { setRetypePassword(e.target.value) }}
6565
/>
6666
</FormControl>
6767
<FormControl id='currPassword'>
6868
<FormLabel>Current Password</FormLabel>
69-
<Input type='text'
69+
<Input type='password'
7070
name="currPassword"
7171
value={currPassword}
7272
onChange={(e) => { setCurrPassword(e.target.value) }}

0 commit comments

Comments
 (0)