Environment:
React, Bootstrap, Axios Requisition and saving in sessionStorage
I'm doing a SPA and saving the password in sessionStorage.
In Firefox browser appears to save the password and after saving the same pulls normally.
When I open with Google Chrome it asks if I want to save, I'll go in yes, but at the next login it does not pull the password. is saved, if I enter the browser and go to saved passwords, the login and password that I put appears. but he does not pull.
<Card id="form-login" className="z-depth-2">
<CardImage className="img-fluid" src={img} />
<CardTitle className="text-center"><b>Login</b></CardTitle>
<form>
<Input id="input-user" type="text" label="Codigo do usuario" onChange={(e) => this.setState({ usuarioInformado: e.target.value })} />
<Input type="password" label="Senha" onChange={(e) => this.setState({ senhaInformada: e.target.value })} />
<div className="text-center">
<Button onClick={this.login} value="login" type="submit" className="btn-block" id="btn-login" color="orange darken-4">entrar</Button>
</div>
</form>
</Card>
login:
login = (event) => {
event.preventDefault();
if (!Number.isInteger(Number(this.state.usuarioInformado))) {
this.notify('error', '');
return;
}
if (Number(this.state.usuarioInformado) < 1) {
this.notify('error', '');
return;
}
if (this.state.senhaInformada.length === 0) {
this.notify('error', '');
return;
}
if (this.state.senhaInformada.length > 8) {
this.notify('error', '');
return;
}
axios.get(this.state.server + "/usuario/get?id=" + Number(this.state.usuarioInformado) + "&senha=" + this.state.senhaInformada)
.then(
(result) => {
this.setState(result.data);
if (this.state.status === 1) {
sessionStorage.setItem("usuario", this.state.usuarioInformado);
sessionStorage.setItem("senha", this.state.senhaInformada);
sessionStorage.setItem("nome", this.state.usuario.nome);
sessionStorage.setItem("system", this.state.usuario.system);
sessionStorage.setItem("admin", this.state.usuario.admin);
sessionStorage.setItem("user", this.state.usuario.user);
sessionStorage.setItem("empresa", this.state.usuario.empresa);
window.location.href = Front + "/menu";
} else if (this.state.status === 0) {
this.notify('servidor', this.state.mensagem);
}
}
);
}
Button action quit:
deslogar = () => {
sessionStorage.clear();
window.location.href = Front;
}
Can this be a problem with how Chrome handles sessionStorage? because in Firefox it works perfectly