Skip to content

Commit

Permalink
对于需要登录,或者已经登录的某些页面进行跳转.
Browse files Browse the repository at this point in the history
  • Loading branch information
TeemoWan committed Jan 24, 2016
1 parent 36b486c commit cb46da4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2014-01-24
1.需求,文档编辑器
2.需求,图片上传
https://developer.qiniu.com/docs/v6/sdk/javascript-sdk.html
https://github.com/qiniu/js-sdk/
https://github.com/moxiecode/plupload

3.需求,测试
https://www.npmjs.com/package/mocha
https://www.npmjs.com/package/chai
https://www.npmjs.com/package/enzyme
https://www.npmjs.com/package/sinon

4.需求,权限

2016-01-23
1.kadira:flow-router-ssr 目前服务器端渲染无效.
2.用户退出,Header不刷新.
Expand Down
18 changes: 18 additions & 0 deletions client/configs/routes.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {injectDeps} from 'react-simple-di';
import {mount} from 'react-mounter';
import {Meteor} from 'meteor/meteor';
import {FlowRouter} from 'meteor/kadira:flow-router';
import MainLayout from '../components/MainLayout/index.jsx';
import AuthLayout from '../components/AuthLayout/index.jsx';
Expand All @@ -16,6 +17,18 @@ import DocumentIndex from '../containers/documentIndex';
import DocumentAdd from '../containers/documentAdd';
import Document from '../containers/document';

const checkLoggedIn = () => {
if (!Meteor.loggingIn() && !Meteor.userId()) {
FlowRouter.go('/login');
}
};

const redirectIfLoggedIn = (ctx, redirect) => {
if (Meteor.userId()) {
redirect('/');
}
};

export const initRoutes = (context, actions) => {
const MainLayoutCtx = injectDeps(context, actions)(MainLayout);
const AuthLayoutCtx = injectDeps(context, actions)(AuthLayout);
Expand All @@ -29,20 +42,23 @@ export const initRoutes = (context, actions) => {

FlowRouter.route('/login', {
name: 'login',
triggersEnter: [redirectIfLoggedIn],
action: function () {
mount(AuthLayoutCtx, {content: () => (<Login />)});
}
});

FlowRouter.route('/register', {
name: 'register',
triggersEnter: [redirectIfLoggedIn],
action: function () {
mount(AuthLayoutCtx, {content: () => (<Register />)});
}
});

FlowRouter.route('/forgotPassword', {
name: 'forgotPassword',
triggersEnter: [redirectIfLoggedIn],
action: function () {
mount(AuthLayoutCtx, {content: () => (<ForgotPassword />)});
}
Expand All @@ -57,6 +73,7 @@ export const initRoutes = (context, actions) => {

FlowRouter.route('/team/add', {
name: 'teamAdd',
triggersEnter: [checkLoggedIn],
action: function () {
mount(MainLayoutCtx, {content: () => (<TeamAdd />)});
}
Expand All @@ -78,6 +95,7 @@ export const initRoutes = (context, actions) => {

FlowRouter.route('/document/add', {
name: 'documentAdd',
triggersEnter: [checkLoggedIn],
action: function () {
mount(MainLayoutCtx, {content: () => (<DocumentAdd />)});
}
Expand Down

0 comments on commit cb46da4

Please sign in to comment.