Skip to content

Commit

Permalink
fix second password
Browse files Browse the repository at this point in the history
  • Loading branch information
salomegeo committed May 30, 2018
1 parent 98ac6ba commit c659b25
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as AT from './actionTypes'

export const toggleSecondPassword = (password) => ({ type: AT.TOGGLE_SECOND_PASSWORD, payload: { password } })
export const toggleSecondPassword = (password, secondPasswordEnabled) => ({ type: AT.TOGGLE_SECOND_PASSWORD, payload: { password, secondPasswordEnabled } })

export const updatePbkdf2Iterations = (iterations) => ({ type: AT.UPDATE_PBKDF2_ITERATIONS, payload: { iterations } })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ export default ({ coreSagas }) => {
}

const toggleSecondPassword = function * (action) {
const { password } = action.payload
const { password, secondPasswordEnabled } = action.payload
try {
yield call(coreSagas.wallet.toggleSecondPassword, { password })
yield put(actions.alerts.displaySuccess('Second password toggle successful.'))
if (secondPasswordEnabled) {
yield put(actions.alerts.displaySuccess('Second password disabled successfully.'))
} else {
yield put(actions.alerts.displaySuccess('Second password enabled successfuly.'))
}
} catch (error) {
yield put(actions.logs.logErrorMessage(logLocation, 'toggleSecondPassword', error))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class SettingsContainer extends React.PureComponent {

onSubmit (e) {
e.preventDefault()
const { secondPasswordValue } = this.props
this.props.walletActions.toggleSecondPassword(secondPasswordValue)
const { secondPasswordValue, secondPasswordEnabled } = this.props
this.props.walletActions.toggleSecondPassword(secondPasswordValue, secondPasswordEnabled)
this.handleToggle()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ButtonWrapper = styled(ButtonGroup)`
`

const Settings = (props) => {
const { updateToggled, handleToggle, handleSubmit, mainPassword, submitting, invalid, secondPasswordEnabled, handleCancel } = props
const { updateToggled, handleToggle, onSubmit, mainPassword, submitting, invalid, secondPasswordEnabled, handleCancel } = props
const isMainPassword = (props) => mainPassword !== props ? null : "You can't use your main password as your second password."
if (secondPasswordEnabled) {
return (
Expand All @@ -30,7 +30,7 @@ const Settings = (props) => {
</Button>
}
{ updateToggled &&
<SettingForm onSubmit={handleSubmit}>
<SettingForm onSubmit={onSubmit}>
<Text size='14px' weight={300}>
<FormattedMessage id='scenes.securitysettings.basicsecurity.secondpasswordwallet.settings.label' defaultMessage='Second Password' />
</Text>
Expand All @@ -39,8 +39,8 @@ const Settings = (props) => {
<Button nature='empty' capitalize onClick={handleCancel}>
<FormattedMessage id='scenes.securitysettings.basicsecurity.secondpasswordwallet.settings.cancel' defaultMessage='Cancel' />
</Button>
<Button nature='primary' capitalize disabled={submitting || invalid} onClick={handleSubmit}>
<FormattedMessage id='scenes.securitysettings.basicsecurity.secondpasswordwallet.settings.remove' defaultMessage='Remove Second Password' />
<Button nature='primary' capitalize disabled={submitting || invalid} onClick={onSubmit}>
<FormattedMessage id='scenes.securitysettings.basicsecurity.secondpasswordwallet.settings.confirmremove' defaultMessage='Remove' />
</Button>
</ButtonWrapper>
</SettingForm>
Expand Down Expand Up @@ -86,7 +86,7 @@ const Settings = (props) => {
<Button nature='empty' capitalize onClick={handleCancel}>
<FormattedMessage id='scenes.securitysettings.basicsecurity.secondpasswordwallet.settings.cancel2' defaultMessage='Cancel' />
</Button>
<Button nature='primary' capitalize disabled={submitting || invalid} onClick={handleSubmit}>
<Button nature='primary' capitalize disabled={submitting || invalid} onClick={onSubmit}>
<FormattedMessage id='scenes.securitysettings.basicsecurity.secondpasswordwallet.settings.save2' defaultMessage='Save' />
</Button>
</ButtonWrapper>
Expand All @@ -100,7 +100,7 @@ const Settings = (props) => {
Settings.propTypes = {
updateToggled: PropTypes.bool.isRequired,
handleToggle: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired
onSubmit: PropTypes.func.isRequired
}

export default reduxForm({ form: 'settingSecondPassword' })(Settings)

0 comments on commit c659b25

Please sign in to comment.