Fix warning in Example project when failing to load credentials
This commit is contained in:
parent
fcd76decbf
commit
eeeb703278
|
@ -21,10 +21,10 @@ export default class KeychainExample extends Component {
|
||||||
Keychain
|
Keychain
|
||||||
.setGenericPassword(this.state.username, this.state.password)
|
.setGenericPassword(this.state.username, this.state.password)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState({status: 'Credentials saved!'});
|
this.setState({ status: 'Credentials saved!' });
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.setState({status: 'Could not save credentials, ' + err});
|
this.setState({ status: 'Could not save credentials, ' + err });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,14 @@ export default class KeychainExample extends Component {
|
||||||
Keychain
|
Keychain
|
||||||
.getGenericPassword()
|
.getGenericPassword()
|
||||||
.then((credentials) => {
|
.then((credentials) => {
|
||||||
this.setState(credentials);
|
if (credentials) {
|
||||||
this.setState({status: 'Credentials loaded!'});
|
this.setState({ ...credentials, status: 'Credentials loaded!' });
|
||||||
|
} else {
|
||||||
|
this.setState({ status: 'No credentials stored.' });
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.setState({status: 'Could not load credentials. ' + err});
|
this.setState({ status: 'Could not load credentials. ' + err });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +47,10 @@ export default class KeychainExample extends Component {
|
||||||
Keychain
|
Keychain
|
||||||
.resetGenericPassword()
|
.resetGenericPassword()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setState({status: 'Credentials Reset!', username: '', password: '' });
|
this.setState({ status: 'Credentials Reset!', username: '', password: '' });
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.setState({status: 'Could not reset credentials, ' + err});
|
this.setState({ status: 'Could not reset credentials, ' + err });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue