mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Merge pull request #739 from mewtaylor/issue/gh-698
Fix GH-698: refresh session on successful registration
This commit is contained in:
commit
bf28fae97c
1 changed files with 20 additions and 3 deletions
|
@ -1,8 +1,10 @@
|
|||
var connect = require('react-redux').connect;
|
||||
var defaults = require('lodash.defaultsdeep');
|
||||
var React = require('react');
|
||||
var render = require('../../lib/render.jsx');
|
||||
|
||||
var api = require('../../lib/api');
|
||||
var sessionActions = require('../../redux/session.js');
|
||||
|
||||
var Deck = require('../../components/deck/deck.jsx');
|
||||
var Progression = require('../../components/progression/progression.jsx');
|
||||
|
@ -67,12 +69,16 @@ var TeacherRegistration = React.createClass({
|
|||
}, function (err, res) {
|
||||
this.setState({waiting: false});
|
||||
if (err) return this.setState({registrationError: err});
|
||||
if (res[0].success) return this.advanceStep(formData);
|
||||
if (res[0].success) {
|
||||
this.props.dispatch(sessionActions.refreshSession());
|
||||
return this.advanceStep(formData);
|
||||
}
|
||||
this.setState({registrationError: res[0].msg});
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
render: function () {
|
||||
var permissions = this.props.session.permissions || {};
|
||||
return (
|
||||
<Deck className="teacher-registration">
|
||||
{this.state.registrationError ?
|
||||
|
@ -101,7 +107,10 @@ var TeacherRegistration = React.createClass({
|
|||
waiting={this.state.waiting} />
|
||||
<Steps.EmailStep onNextStep={this.register}
|
||||
waiting={this.state.waiting} />
|
||||
<Steps.TeacherApprovalStep email={this.state.formData.user && this.state.formData.user.email} />
|
||||
<Steps.TeacherApprovalStep email={this.state.formData.user && this.state.formData.user.email}
|
||||
confirmed={permissions.social}
|
||||
invited={permissions.educator_invitee}
|
||||
educator={permissions.educator} />
|
||||
</Progression>
|
||||
}
|
||||
</Deck>
|
||||
|
@ -109,4 +118,12 @@ var TeacherRegistration = React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
render(<TeacherRegistration />, document.getElementById('app'));
|
||||
var mapStateToProps = function (state) {
|
||||
return {
|
||||
session: state.session.session
|
||||
};
|
||||
};
|
||||
|
||||
var ConnectedTeacherRegistration = connect(mapStateToProps)(TeacherRegistration);
|
||||
|
||||
render(<ConnectedTeacherRegistration />, document.getElementById('app'));
|
||||
|
|
Loading…
Reference in a new issue