From 4b703bb4cc275fe817ef5dfc1e001ffc976eac2d Mon Sep 17 00:00:00 2001 From: Youssef Date: Thu, 30 Dec 2021 10:57:35 +0100 Subject: [PATCH 01/23] feat: add show password for all passwords input --- .../admin/users/change-password-component.jsx | 62 ++++++++++++++++++- .../component/user/HostedAuth/HostedAuth.jsx | 45 +++++++++++++- .../user/PasswordAuth/PasswordAuth.jsx | 41 +++++++++++- .../UserProfile/EditProfile/EditProfile.tsx | 55 ++++++++++++++-- .../ResetPasswordForm/ResetPasswordForm.tsx | 61 +++++++++++++++++- 5 files changed, 250 insertions(+), 14 deletions(-) diff --git a/frontend/src/component/admin/users/change-password-component.jsx b/frontend/src/component/admin/users/change-password-component.jsx index cb040e043b..6027c7aa16 100644 --- a/frontend/src/component/admin/users/change-password-component.jsx +++ b/frontend/src/component/admin/users/change-password-component.jsx @@ -1,7 +1,14 @@ import { useState } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import { TextField, Typography, Avatar } from '@material-ui/core'; +import { + TextField, + Typography, + Avatar, + InputAdornment, + IconButton, +} from '@material-ui/core'; +import { Visibility, VisibilityOff } from '@material-ui/icons'; import { trim } from '../../common/util'; import { modalStyles } from './util'; import Dialogue from '../../common/Dialogue/Dialogue'; @@ -20,8 +27,17 @@ function ChangePassword({ const [data, setData] = useState({}); const [error, setError] = useState({}); const [validPassword, setValidPassword] = useState(false); + const [showPassword, setShowPassword] = useState(false); const commonStyles = useCommonStyles(); + const handleClickShowPassword = () => { + setShowPassword(!showPassword); + }; + + const handleMouseDownPassword = e => { + e.preventDefault(); + }; + const updateField = e => { setError({}); setData({ @@ -112,23 +128,63 @@ function ChangePassword({ + + {showPassword ? ( + + ) : ( + + )} + + + ), + }} /> + + {showPassword ? ( + + ) : ( + + )} + + + ), + }} /> { const params = useQueryParams(); const [username, setUsername] = useState(params.get('email') || ''); const [password, setPassword] = useState(''); + const [showPassword, setShowPassword] = useState(false); const [errors, setErrors] = useState({ usernameError: '', passwordError: '', }); + const handleClickShowPassword = () => { + setShowPassword(!showPassword); + }; + + const handleMouseDownPassword = e => { + e.preventDefault(); + }; + const handleSubmit = async evt => { evt.preventDefault(); @@ -113,12 +130,36 @@ const HostedAuth = ({ authDetails, passwordLogin }) => { label="Password" onChange={evt => setPassword(evt.target.value)} name="password" - type="password" + type={showPassword ? 'text' : 'password'} value={password} error={!!passwordError} helperText={passwordError} variant="outlined" size="small" + InputProps={{ + style:{ + paddingRight: 0 + }, + endAdornment: ( + + + {showPassword ? ( + + ) : ( + + )} + + + ), + }} />