mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-22 23:27:54 -05:00
Refresh session, close popup after registration
This commit is contained in:
parent
6b1ce8549e
commit
fcec859cbe
2 changed files with 18 additions and 2 deletions
|
@ -96,6 +96,10 @@ var Navigation = React.createClass({
|
|||
closeRegistration: function () {
|
||||
this.setState({'registrationOpen': false});
|
||||
},
|
||||
completeRegistration: function () {
|
||||
window.refreshSession();
|
||||
this.closeRegistration();
|
||||
},
|
||||
render: function () {
|
||||
var classes = classNames({
|
||||
'inner': true,
|
||||
|
@ -151,7 +155,8 @@ var Navigation = React.createClass({
|
|||
<Registration
|
||||
key="registration"
|
||||
isOpen={this.state.registrationOpen}
|
||||
onRequestClose={this.closeRegistration} />,
|
||||
onRequestClose={this.closeRegistration}
|
||||
onRegistrationDone={this.completeRegistration} />,
|
||||
<li className="link right login-item" key="login">
|
||||
<a
|
||||
href="#"
|
||||
|
|
|
@ -7,9 +7,20 @@ Modal.setAppElement(document.getElementById('view'));
|
|||
|
||||
module.exports = React.createClass({
|
||||
propTypes: {
|
||||
isOpen: React.PropTypes.func,
|
||||
isOpen: React.PropTypes.bool,
|
||||
onRegistrationDone: React.PropTypes.func,
|
||||
onRequestClose: React.PropTypes.func
|
||||
},
|
||||
onMessage: function (e) {
|
||||
if (e.origin != window.location.origin) return;
|
||||
if (e.data == 'registration-done') this.props.onRegistrationDone();
|
||||
},
|
||||
componentDidMount: function () {
|
||||
window.addEventListener('message', this.onMessage);
|
||||
},
|
||||
componentWillUnmount: function () {
|
||||
window.removeEventListener('message', this.onMessage);
|
||||
},
|
||||
render: function () {
|
||||
return (
|
||||
<Modal
|
||||
|
|
Loading…
Reference in a new issue