mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
refactor handleRegistrationResponse
This commit is contained in:
parent
643b4a611b
commit
1d976c7cdf
1 changed files with 38 additions and 34 deletions
|
@ -27,6 +27,7 @@ class JoinFlow extends React.Component {
|
||||||
bindAll(this, [
|
bindAll(this, [
|
||||||
'handleAdvanceStep',
|
'handleAdvanceStep',
|
||||||
'handlePrepareToRegister',
|
'handlePrepareToRegister',
|
||||||
|
'handleRegistrationResponse',
|
||||||
'handleSubmitRegistration'
|
'handleSubmitRegistration'
|
||||||
]);
|
]);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -45,29 +46,7 @@ class JoinFlow extends React.Component {
|
||||||
this.handleSubmitRegistration(this.state.formData);
|
this.handleSubmitRegistration(this.state.formData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleSubmitRegistration (formData) {
|
handleRegistrationResponse (err, body, res) {
|
||||||
this.setState({waiting: true}, () => {
|
|
||||||
api({
|
|
||||||
host: '',
|
|
||||||
uri: '/accounts/register_new_user/',
|
|
||||||
method: 'post',
|
|
||||||
useCsrf: true,
|
|
||||||
formData: {
|
|
||||||
'username': formData.username,
|
|
||||||
'email': formData.email,
|
|
||||||
'password': formData.password,
|
|
||||||
'birth_month': formData.birth_month,
|
|
||||||
'birth_year': formData.birth_year,
|
|
||||||
'g-recaptcha-response': null,
|
|
||||||
'gender': formData.gender,
|
|
||||||
'country': formData.country,
|
|
||||||
'subscribe': true,
|
|
||||||
'is_robot': formData.yesno
|
|
||||||
// no need to include csrfmiddlewaretoken; will be provided in
|
|
||||||
// X-CSRFToken header, which scratchr2 looks for in
|
|
||||||
// scratchr2/middleware/csrf.py line 237.
|
|
||||||
}
|
|
||||||
}, (err, body, res) => {
|
|
||||||
this.setState({waiting: false}, () => {
|
this.setState({waiting: false}, () => {
|
||||||
let errStr = '';
|
let errStr = '';
|
||||||
if (!err && res.statusCode === 200) {
|
if (!err && res.statusCode === 200) {
|
||||||
|
@ -102,6 +81,31 @@ class JoinFlow extends React.Component {
|
||||||
})} (${res.statusCode})`
|
})} (${res.statusCode})`
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
handleSubmitRegistration (formData) {
|
||||||
|
this.setState({waiting: true}, () => {
|
||||||
|
api({
|
||||||
|
host: '',
|
||||||
|
uri: '/accounts/register_new_user/',
|
||||||
|
method: 'post',
|
||||||
|
useCsrf: true,
|
||||||
|
formData: {
|
||||||
|
'username': formData.username,
|
||||||
|
'email': formData.email,
|
||||||
|
'password': formData.password,
|
||||||
|
'birth_month': formData.birth_month,
|
||||||
|
'birth_year': formData.birth_year,
|
||||||
|
'g-recaptcha-response': null,
|
||||||
|
'gender': formData.gender,
|
||||||
|
'country': formData.country,
|
||||||
|
'subscribe': true,
|
||||||
|
'is_robot': formData.yesno
|
||||||
|
// no need to include csrfmiddlewaretoken; will be provided in
|
||||||
|
// X-CSRFToken header, which scratchr2 looks for in
|
||||||
|
// scratchr2/middleware/csrf.py line 237.
|
||||||
|
}
|
||||||
|
}, (err, body, res) => {
|
||||||
|
this.handleRegistrationResponse(err, body, res);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue