|
1 | | -import { Button, TextField } from '@mui/material'; |
| 1 | +import { Button, TextField, InputAdornment, IconButton } from '@mui/material'; |
| 2 | +import { Visibility, VisibilityOff } from '@mui/icons-material'; |
2 | 3 | import { withStyles } from '@mui/styles'; |
3 | 4 | import { useQueryClient } from '@tanstack/react-query'; |
4 | 5 | import PropTypes from 'prop-types'; |
@@ -47,6 +48,7 @@ const Login = ({ classes }) => { |
47 | 48 | const [successLine, setSuccessLine] = useState(''); |
48 | 49 | const [warningLine, setWarningLine] = useState(''); |
49 | 50 | const [loginCount, setLoginCount] = useState(0); |
| 51 | + const [showPassword, setShowPassword] = useState(false); |
50 | 52 |
|
51 | 53 | const { data: dataAuth, isSuccess: isSuccessAuth, isFetching: isFetchingAuth } = useFetchData(['get-auth'], {}, METHOD.POST); |
52 | 54 | useEffect(() => { |
@@ -301,6 +303,12 @@ const Login = ({ classes }) => { |
301 | 303 | setAppContextValue('openVerifySecretCodeModalDialog', true); |
302 | 304 | }; |
303 | 305 |
|
| 306 | + const handleClickShowPassword = () => setShowPassword((show) => !show); |
| 307 | + |
| 308 | + const handleMouseDownPassword = (event) => { |
| 309 | + event.preventDefault(); |
| 310 | + }; |
| 311 | + |
304 | 312 | // console.log(getAppContextData()); |
305 | 313 | const isAdmin = viewerCanSeeOrDo(['canAddTeamMemberAnyTeam'], viewerAccessRights); |
306 | 314 | const isAuthSafe = getAppContextValue('isAuthenticated') || false; |
@@ -399,19 +407,47 @@ const Login = ({ classes }) => { |
399 | 407 | <TextField id="password" |
400 | 408 | label="Password" |
401 | 409 | variant="outlined" |
402 | | - // type="password" |
| 410 | + type={showPassword ? 'text' : 'password'} |
403 | 411 | autoComplete="current-password" |
404 | 412 | inputRef={passwordFldRef} |
405 | 413 | // defaultValue="12345678" |
406 | 414 | 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 | + }} |
407 | 429 | /> |
408 | 430 | <TextField id="confirmPassword" |
409 | 431 | label="Confirm Password" |
410 | 432 | variant="outlined" |
411 | | - // type="password" |
| 433 | + type={showPassword ? 'text' : 'password'} |
412 | 434 | inputRef={confirmPasswordFldRef} |
413 | 435 | // defaultValue="12345678" |
414 | 436 | 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 | + }} |
415 | 451 | /> |
416 | 452 | </span> |
417 | 453 | <span style={{ display: 'flex' }}> |
|
0 commit comments