Skip to content

Commit

Permalink
Bug fix for logic for setting token for re-authenticated accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschaich committed May 15, 2019
1 parent 608927b commit b4ac9b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/components/account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Account = props => {
'Content-Type': 'application/json'
}
}).then(data => {
props.handleOnUpdateAccountResponse(data)
props.handleOnUpdateAccountResponse(data, props.details.nickname)
})
}

Expand Down
30 changes: 16 additions & 14 deletions src/components/accounts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Link from 'next/link'
class Accounts extends React.Component {
constructor(props) {
super(props)
this.state = { newAccountNickname: '', accounts: false }
this.state = { currentAccountNickname: '', accounts: false }
}

componentDidMount = async () => {
Expand All @@ -18,7 +18,7 @@ class Accounts extends React.Component {
}

handleOnNewAccountNameChange = e => {
this.setState({ newAccountNickname: e.currentTarget.value })
this.setState({ currentAccountNickname: e.currentTarget.value })
}

handleOnSuccess = (public_token, metadata) => {
Expand All @@ -27,7 +27,7 @@ class Accounts extends React.Component {
}
const body = {
public_token,
accountNickname: this.state.newAccountNickname
accountNickname: this.state.currentAccountNickname
}
fetch(`http://${process.env.HOST}:${process.env.PORT}/token`, {
method: 'POST',
Expand All @@ -38,16 +38,18 @@ class Accounts extends React.Component {
})
}

handleOnUpdateAccountResponse = data => {
window.Plaid.create({
clientName: 'Mintable',
env: this.props.config.PLAID_ENVIRONMENT,
product: ['auth', 'transactions'],
key: this.props.config.PLAID_PUBLIC_KEY,
onExit: this.handleOnExit,
onSuccess: this.handleOnSuccess,
token: data
}).open()
handleOnUpdateAccountResponse = (data, nickname) => {
this.setState({ currentAccountNickname: nickname }, () =>
window.Plaid.create({
clientName: 'Mintable',
env: this.props.config.PLAID_ENVIRONMENT,
product: ['auth', 'transactions'],
key: this.props.config.PLAID_PUBLIC_KEY,
onExit: this.handleOnExit,
onSuccess: this.handleOnSuccess,
token: data
}).open()
)
}

render = () => {
Expand Down Expand Up @@ -102,7 +104,7 @@ class Accounts extends React.Component {
onSuccess={this.handleOnSuccess}
style={{
background: '#137cbd',
display: this.state.newAccountNickname ? 'flex' : 'none'
display: this.state.currentAccountNickname ? 'flex' : 'none'
}}
>
Add New Account
Expand Down

0 comments on commit b4ac9b6

Please sign in to comment.