Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show password feature #1463

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/components/Account/Login/Login.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { login } from './Login.actions';
import messages from './Login.messages';
import './Login.css';

import InputAdornment from '@material-ui/core/InputAdornment';
import IconButton from '@material-ui/core/IconButton';
import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff';

export class Login extends Component {
static propTypes = {
intl: intlShape.isRequired,
Expand All @@ -30,6 +35,11 @@ export class Login extends Component {
loginStatus: {}
};

passState = {
password: '',
showPassword: false,
};

handleSubmit = values => {
const { login } = this.props;

Expand All @@ -49,6 +59,8 @@ export class Login extends Component {

const isButtonDisabled = isLogging || !!loginStatus.success;

var showPassword = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A state should be used for this. This is the reason why you need to type a new character to see the password.


return (
<Dialog open={isDialogOpen} onClose={onClose} aria-labelledby="login">
<DialogTitle id="login">
Expand Down Expand Up @@ -78,9 +90,19 @@ export class Login extends Component {
<TextField
error={errors.password}
label={intl.formatMessage(messages.password)}
type="password"
type={showPassword ? "text" : "password"}
name="password"
onChange={handleChange}
onChange={handleChange('password')}
InputProps={{
endAdornment: <InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
onClick={() => { showPassword = !showPassword; }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is problematic, updating a variable instead of state

>
{showPassword ? <Visibility /> : <VisibilityOff />}
</IconButton>
</InputAdornment>,
}}
/>
<DialogActions>
<Button
Expand Down