Skip to content

Commit e0d6216

Browse files
authored
Merge pull request #141 from pravingv/develop
[WV-2476]In WeConnect, update all of the password fields to default to obscuring the password as you type it [TEAM REVIEW]
2 parents 43af575 + 8c6e092 commit e0d6216

2 files changed

Lines changed: 80 additions & 6 deletions

File tree

src/js/components/Login/ResetYourPassword.jsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Modal } from '@mui/material';
1+
import { Modal, InputAdornment, IconButton } from '@mui/material';
2+
import { Visibility, VisibilityOff } from '@mui/icons-material';
23
import Button from '@mui/material/Button';
34
import Dialog from '@mui/material/Dialog';
45
import DialogContent from '@mui/material/DialogContent';
@@ -30,6 +31,8 @@ const ResetYourPassword = ({ openDialog, closeDialog }) => {
3031
const [warningLine, setWarningLine] = useState('');
3132
const [errorMessage, setErrorMessage] = useState('');
3233
const [personId, setPersonId] = useState('');
34+
const [showPassword, setShowPassword] = useState(false);
35+
const [showPassword1, setShowPassword1] = useState(false);
3336

3437
const emailRef = useRef('');
3538
const emailPersonalRef = useRef('');
@@ -151,6 +154,13 @@ const ResetYourPassword = ({ openDialog, closeDialog }) => {
151154
);
152155
}
153156

157+
const handleClickShowPassword = () => setShowPassword((show) => !show);
158+
const handleClickShowPassword1 = () => setShowPassword1((show) => !show);
159+
160+
const handleMouseDownPassword = (event) => {
161+
event.preventDefault();
162+
};
163+
154164
return (
155165
<>
156166
<Modal
@@ -190,24 +200,52 @@ const ResetYourPassword = ({ openDialog, closeDialog }) => {
190200
id="field1"
191201
inputRef={password1Ref}
192202
label="Password"
193-
// type="password"
203+
type={showPassword ? 'text' : 'password'}
194204
margin="dense"
195205
name="password1"
196206
required
197207
variant="outlined"
198208
// sx={{ '-webkit-text-security': 'disc' }}
209+
InputProps={{
210+
endAdornment: (
211+
<InputAdornment position="end">
212+
<IconButton
213+
aria-label="toggle password visibility"
214+
onClick={handleClickShowPassword}
215+
onMouseDown={handleMouseDownPassword}
216+
edge="end"
217+
>
218+
{showPassword ? <VisibilityOff /> : <Visibility />}
219+
</IconButton>
220+
</InputAdornment>
221+
),
222+
}}
199223
/>
200224
<TextField
201225
fullWidth
202226
id="field2"
203227
inputRef={password2Ref}
204228
label="Verify Password"
205-
// type="password"
229+
type={showPassword1 ? 'text' : 'password'}
206230
margin="dense"
207231
name="password2"
208232
required
209233
variant="outlined"
210234
// sx={{ '-webkit-text-security': 'disc' }}
235+
InputProps={{
236+
endAdornment: (
237+
<InputAdornment position="end">
238+
<IconButton
239+
aria-label="toggle password visibility"
240+
onClick={handleClickShowPassword1}
241+
onMouseDown={handleMouseDownPassword}
242+
edge="end"
243+
>
244+
{showPassword1 ? <VisibilityOff /> : <Visibility />}
245+
</IconButton>
246+
</InputAdornment>
247+
),
248+
}}
211249
/>
212250
</>
213251
)}

src/js/pages/Login.jsx

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Button, TextField } from '@mui/material';
1+
import { Button, TextField, InputAdornment, IconButton } from '@mui/material';
2+
import { Visibility, VisibilityOff } from '@mui/icons-material';
23
import { withStyles } from '@mui/styles';
34
import { useQueryClient } from '@tanstack/react-query';
45
import PropTypes from 'prop-types';
@@ -47,6 +48,7 @@ const Login = ({ classes }) => {
4748
const [successLine, setSuccessLine] = useState('');
4849
const [warningLine, setWarningLine] = useState('');
4950
const [loginCount, setLoginCount] = useState(0);
51+
const [showPassword, setShowPassword] = useState(false);
5052

5153
const { data: dataAuth, isSuccess: isSuccessAuth, isFetching: isFetchingAuth } = useFetchData(['get-auth'], {}, METHOD.POST);
5254
useEffect(() => {
@@ -301,6 +303,12 @@ const Login = ({ classes }) => {
301303
setAppContextValue('openVerifySecretCodeModalDialog', true);
302304
};
303305

306+
const handleClickShowPassword = () => setShowPassword((show) => !show);
307+
308+
const handleMouseDownPassword = (event) => {
309+
event.preventDefault();
310+
};
311+
304312
// console.log(getAppContextData());
305313
const isAdmin = viewerCanSeeOrDo(['canAddTeamMemberAnyTeam'], viewerAccessRights);
306314
const isAuthSafe = getAppContextValue('isAuthenticated') || false;
@@ -399,19 +407,47 @@ const Login = ({ classes }) => {
399407
<TextField id="password"
400408
label="Password"
401409
variant="outlined"
402-
// type="password"
410+
type={showPassword ? 'text' : 'password'}
403411
autoComplete="current-password"
404412
inputRef={passwordFldRef}
405413
// defaultValue="12345678"
406414
sx={{ display: 'block', paddingBottom: '15px' }}
415+
InputProps={{
416+
endAdornment: (
417+
<InputAdornment position="end">
418+
<IconButton
419+
aria-label="toggle password visibility"
420+
onClick={handleClickShowPassword}
421+
onMouseDown={handleMouseDownPassword}
422+
edge="end"
423+
>
424+
{showPassword ? <VisibilityOff /> : <Visibility />}
425+
</IconButton>
426+
</InputAdornment>
427+
),
428+
}}
407429
/>
408430
<TextField id="confirmPassword"
409431
label="Confirm Password"
410432
variant="outlined"
411-
// type="password"
433+
type={showPassword ? 'text' : 'password'}
412434
inputRef={confirmPasswordFldRef}
413435
// defaultValue="12345678"
414436
sx={{ padding: '0 0 15px 10px', display: showCreateStuff ? 'block' : 'none' }}
437+
InputProps={{
438+
endAdornment: (
439+
<InputAdornment position="end">
440+
<IconButton
441+
aria-label="toggle password visibility"
442+
onClick={handleClickShowPassword}
443+
onMouseDown={handleMouseDownPassword}
444+
edge="end"
445+
>
446+
{showPassword ? <VisibilityOff /> : <Visibility />}
447+
</IconButton>
448+
</InputAdornment>
449+
),
450+
}}
415451
/>
416452
</span>
417453
<span style={{ display: 'flex' }}>

0 commit comments

Comments
 (0)