Skip to content

Commit

Permalink
Add password visibility icon in login dialog
Browse files Browse the repository at this point in the history
Add a visibilty button in the password field of login page to show/hide the password as required.
  • Loading branch information
soun059 authored and longsleep committed Jul 16, 2024
1 parent 97c02fe commit 5fabe20
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion identifier/src/containers/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import DialogContent from '@material-ui/core/DialogContent';

import { updateInput, executeLogonIfFormValid, advanceLogonFlow } from '../../actions/login';
import { ErrorMessage } from '../../errors';
import IconButton from '@material-ui/core/IconButton';
import InputAdornment from '@material-ui/core/InputAdornment'
import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff';

const styles = theme => ({
button: {
Expand Down Expand Up @@ -67,6 +71,8 @@ function Login(props) {

const { t } = useTranslation();

const [showPassword, setShowPassword] = React.useState(false);

useEffect(() => {
if (hello && hello.state && history.action !== 'PUSH') {
if (!query.prompt || query.prompt.indexOf('select_account') === -1) {
Expand Down Expand Up @@ -134,14 +140,28 @@ function Login(props) {
className={classes.usernameInputField}
/>
<TextField
type="password"
type={showPassword ? "text" : "password"}
label={t("konnect.login.passwordField.label", "Password")}
error={!!errors.password}
helperText={<ErrorMessage error={errors.password}></ErrorMessage>}
fullWidth
onChange={handleChange('password')}
autoComplete="kopano-account current-password"
variant="outlined"
InputProps={{ // End-adornment icon to show/hide password on visibility button click.
endAdornment: <InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={() => setShowPassword((show) => !show)}
onMouseDown={(event) => {
event.preventDefault();
}}
edge="end"
>
{showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton>
</InputAdornment>
}}
/>
<DialogActions>
<div className={classes.wrapper}>
Expand Down

0 comments on commit 5fabe20

Please sign in to comment.