fix async user generation

This commit is contained in:
LowEntropyFace 2022-01-09 09:43:47 -05:00
parent 229294b878
commit aa8e1f50a2

View File

@ -26,7 +26,7 @@ export default class UserGenPage extends Component {
this.state = { this.state = {
token: this.genBase62Token(32), token: this.genBase62Token(32),
}; };
this.getGeneratedUser(); this.getGeneratedUser(this.state.token);
} }
// sort of cryptographically strong function to generate Base62 token client-side // sort of cryptographically strong function to generate Base62 token client-side
@ -40,8 +40,8 @@ export default class UserGenPage extends Component {
.substring(0, length); .substring(0, length);
} }
getGeneratedUser() { getGeneratedUser(token) {
fetch('/api/user' + '?token=' + this.state.token) fetch('/api/user' + '?token=' + token)
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
this.setState({ this.setState({
@ -82,7 +82,7 @@ export default class UserGenPage extends Component {
this.setState({ this.setState({
token: e.target.value, token: e.target.value,
}) })
this.getGeneratedUser(); this.getGeneratedUser(e.target.value);
} }
// TO FIX CSRF TOKEN IS NOT UPDATED UNTIL WINDOW IS RELOADED // TO FIX CSRF TOKEN IS NOT UPDATED UNTIL WINDOW IS RELOADED