mirror of
https://github.com/ascribe/onion.git
synced 2025-01-20 17:51:25 +01:00
add redirect if user is logged in to sign up page
This commit is contained in:
parent
761138dbf6
commit
c478bbce9a
@ -31,6 +31,8 @@ let LoginContainer = React.createClass({
|
|||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
|
||||||
|
// if user is already logged in, redirect him to piece list
|
||||||
if(this.state.currentUser && this.state.currentUser.email) {
|
if(this.state.currentUser && this.state.currentUser.email) {
|
||||||
this.transitionTo('pieces');
|
this.transitionTo('pieces');
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Router from 'react-router';
|
import Router from 'react-router';
|
||||||
|
|
||||||
|
import { mergeOptions } from '../utils/general_utils';
|
||||||
|
|
||||||
|
import UserStore from '../stores/user_store';
|
||||||
|
|
||||||
import GlobalNotificationModel from '../models/global_notification_model';
|
import GlobalNotificationModel from '../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../actions/global_notification_actions';
|
import GlobalNotificationActions from '../actions/global_notification_actions';
|
||||||
@ -17,18 +20,37 @@ import apiUrls from '../constants/api_urls';
|
|||||||
let SignupContainer = React.createClass({
|
let SignupContainer = React.createClass({
|
||||||
mixins: [Router.Navigation],
|
mixins: [Router.Navigation],
|
||||||
|
|
||||||
getInitialState(){
|
getInitialState() {
|
||||||
return ({
|
return mergeOptions({
|
||||||
submitted: false,
|
submitted: false,
|
||||||
message: null
|
message: null
|
||||||
});
|
}, UserStore.getState());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
UserStore.listen(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
UserStore.unlisten(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
|
|
||||||
|
// if user is already logged in, redirect him to piece list
|
||||||
|
if(this.state.currentUser && this.state.currentUser.email) {
|
||||||
|
this.transitionTo('pieces');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handleSuccess(message){
|
handleSuccess(message){
|
||||||
this.setState({
|
this.setState({
|
||||||
submitted: true,
|
submitted: true,
|
||||||
message: message
|
message: message
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.submitted){
|
if (this.state.submitted){
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user