Commit 859877c1 authored by Matthew Taylor's avatar Matthew Taylor

refresh session on successful registration

This is needed to ensure that the approval step displays the correct “Wait for Approval” message. Fixes #698
parent 7461098f
var connect = require('react-redux').connect;
var defaults = require('lodash.defaultsdeep'); var defaults = require('lodash.defaultsdeep');
var React = require('react'); var React = require('react');
var render = require('../../lib/render.jsx'); var render = require('../../lib/render.jsx');
var api = require('../../lib/api'); var api = require('../../lib/api');
var sessionActions = require('../../redux/session.js');
var Deck = require('../../components/deck/deck.jsx'); var Deck = require('../../components/deck/deck.jsx');
var Progression = require('../../components/progression/progression.jsx'); var Progression = require('../../components/progression/progression.jsx');
...@@ -67,12 +69,16 @@ var TeacherRegistration = React.createClass({ ...@@ -67,12 +69,16 @@ var TeacherRegistration = React.createClass({
}, function (err, res) { }, function (err, res) {
this.setState({waiting: false}); this.setState({waiting: false});
if (err) return this.setState({registrationError: err}); 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}); this.setState({registrationError: res[0].msg});
}.bind(this)); }.bind(this));
}, },
render: function () { render: function () {
var permissions = this.props.session.permissions || {};
return ( return (
<Deck className="teacher-registration"> <Deck className="teacher-registration">
{this.state.registrationError ? {this.state.registrationError ?
...@@ -101,7 +107,10 @@ var TeacherRegistration = React.createClass({ ...@@ -101,7 +107,10 @@ var TeacherRegistration = React.createClass({
waiting={this.state.waiting} /> waiting={this.state.waiting} />
<Steps.EmailStep onNextStep={this.register} <Steps.EmailStep onNextStep={this.register}
waiting={this.state.waiting} /> 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> </Progression>
} }
</Deck> </Deck>
...@@ -109,4 +118,12 @@ var TeacherRegistration = React.createClass({ ...@@ -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'));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment