diff --git a/imports/client/app/routes.js b/imports/client/app/routes.js index bdab217..084eb4a 100644 --- a/imports/client/app/routes.js +++ b/imports/client/app/routes.js @@ -10,6 +10,7 @@ import { Meteor } from 'meteor/meteor'; * General Components */ import Index from '/imports/client/views/app/module/Index'; +import NotFound from '/imports/client/views/org/NotFound'; /** * Org Components @@ -22,53 +23,24 @@ import { importCsvController } from '/imports/client/views/org/impo //admin import { StudentDataController } from '/imports/client/views/org/admin/students/index' +//students + +//teachers + +//parents -import NotFound from '/imports/client/views/org/NotFound'; /** * NonOrg Components */ import Signup from '/imports/client/views/nonOrg/enter/SignupView'; +import { NonOrgApp } from '/imports/client/layouts/NonOrgApp'; /** * Invalid Org Components */ -const authenticate = (nextState, replace) => { - if (!Meteor.loggingIn() && !Meteor.userId()) { - replace({ - pathname: '/login', - state: { nextPathname: nextState.location.pathname }, - }); - } -}; - - -const detectOrg = () => { - orgSlug = ""; - var hostnameArray = document.location.hostname.split( "." ); - if(hostnameArray[1]=='localhost'){ - orgSlug = hostnameArray[0]; - } - if(orgSlug!=""){ - Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { - if(res){ - Session.set('orgId', res._id); - Session.set('orgSlug', orgSlug); - render(getOrgRoutes(),document.getElementById('app')); - }else{ - render(getInvalidOrgRoute(),document.getElementById('app')); - } - }); - }else{ - render(getNonOrgRoutes(),document.getElementById('app')); - } -} -const checkSlug = (nextState, replace) => { - orgId = Session.get('orgId'); -} - /** There are three types of routes 1)getOrgRoutes: all the routes that should be present for a registered org @@ -98,7 +70,7 @@ const getInvalidOrgRoute = () => ( const getNonOrgRoutes = () => ( - + @@ -106,6 +78,44 @@ const getNonOrgRoutes = () => ( ) +//Authenticate function to give access to users only +const authenticate = (nextState, replace) => { + if (!Meteor.loggingIn() && !Meteor.userId()) { + replace({ + pathname: '/login', + state: { nextPathname: nextState.location.pathname }, + }); + } +}; + + +/** + +**/ +const detectOrg = () => { + orgSlug = ""; + var hostnameArray = document.location.hostname.split( "." ); + if(hostnameArray[1]=='localhost'){ + orgSlug = hostnameArray[0]; + } + if(orgSlug!=""){ + Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { + if(res){ + Session.set('orgId', res._id); + Session.set('orgSlug', orgSlug); + render(getOrgRoutes(),document.getElementById('app')); + }else{ + render(getInvalidOrgRoute(),document.getElementById('app')); + } + }); + }else{ + render(getNonOrgRoutes(),document.getElementById('app')); + } +} +const checkSlug = (nextState, replace) => { + orgId = Session.get('orgId'); +} + Meteor.startup(() => { detectOrg(); diff --git a/imports/client/layouts/NonOrgApp.js b/imports/client/layouts/NonOrgApp.js index 1a8c89c..687b44a 100644 --- a/imports/client/layouts/NonOrgApp.js +++ b/imports/client/layouts/NonOrgApp.js @@ -1,18 +1,24 @@ -import React from 'react'; -import { Grid } from 'react-bootstrap'; -import AppNavigation from '../containers/AppNavigation.js'; +import React, { Component } from 'react'; +import { Grid } from 'react-bootstrap'; +import {AppNavigationController} from '/imports/client/views/org/app/module/navigation/index'; +/** + * user based redirection will take place here + */ + export class App extends Component { + constructor(props) { + super(props); + this.state = { -const App = ({ children }) => ( -
- - - { children } - -
-); - -App.propTypes = { - children: React.PropTypes.node, -}; - -export default App; + }; + }; + render(){ + return ( +
+ + + { this.props.children } + +
+ ) + } + } diff --git a/imports/client/views/nonOrg/app/module/Index.js b/imports/client/views/nonOrg/app/module/Index.js new file mode 100644 index 0000000..5da010c --- /dev/null +++ b/imports/client/views/nonOrg/app/module/Index.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { Jumbotron } from 'react-bootstrap'; + +const Index = () => ( +
+ +

Base

+

A starting point for Meteor applications.

+

Read the Documentation

+

Currently at v4.11.1

+
+
+); + +export default Index; diff --git a/imports/client/views/nonOrg/app/module/navigation/AppNavigation.js b/imports/client/views/nonOrg/app/module/navigation/AppNavigation.js new file mode 100644 index 0000000..319c936 --- /dev/null +++ b/imports/client/views/nonOrg/app/module/navigation/AppNavigation.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { Navbar } from 'react-bootstrap'; +import { Link } from 'react-router'; +import PublicNavigation from './PublicNavigation.js'; +import AuthenticatedNavigation from './AuthenticatedNavigation.js'; + +const renderNavigation = hasUser => (hasUser ? : ); + +const AppNavigation = ({ hasUser }) => ( + + + + Application Name + + + + + { renderNavigation(hasUser) } + + +); + +AppNavigation.propTypes = { + hasUser: React.PropTypes.object, +}; + +export default AppNavigation; diff --git a/imports/client/views/nonOrg/app/module/navigation/AuthenticatedNavigation.js b/imports/client/views/nonOrg/app/module/navigation/AuthenticatedNavigation.js new file mode 100644 index 0000000..87a0c38 --- /dev/null +++ b/imports/client/views/nonOrg/app/module/navigation/AuthenticatedNavigation.js @@ -0,0 +1,30 @@ +import React from 'react'; +import { browserHistory } from 'react-router'; +import { LinkContainer } from 'react-router-bootstrap'; +import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'; +import { Meteor } from 'meteor/meteor'; + +const handleLogout = () => Meteor.logout(() => browserHistory.push('/login')); + +const userName = () => { + const user = Meteor.user(); + const name = user && user.profile ? user.profile.name : ''; + return user ? `${name.first} ${name.last}` : ''; +}; + +const AuthenticatedNavigation = () => ( +
+ + +
+); + +export default AuthenticatedNavigation; diff --git a/imports/client/views/nonOrg/app/module/navigation/Loading.js b/imports/client/views/nonOrg/app/module/navigation/Loading.js new file mode 100644 index 0000000..c97a7eb --- /dev/null +++ b/imports/client/views/nonOrg/app/module/navigation/Loading.js @@ -0,0 +1,30 @@ +import React from 'react'; + +const Loading = () => ( + + + + + +); + +export default Loading; diff --git a/imports/client/views/nonOrg/app/module/navigation/PublicNavigation.js b/imports/client/views/nonOrg/app/module/navigation/PublicNavigation.js new file mode 100644 index 0000000..d04fc80 --- /dev/null +++ b/imports/client/views/nonOrg/app/module/navigation/PublicNavigation.js @@ -0,0 +1,16 @@ +import React from 'react'; +import { LinkContainer } from 'react-router-bootstrap'; +import { Nav, NavItem } from 'react-bootstrap'; + +const PublicNavigation = () => ( + +); + +export default PublicNavigation; diff --git a/imports/client/views/nonOrg/app/module/navigation/index.js b/imports/client/views/nonOrg/app/module/navigation/index.js new file mode 100644 index 0000000..65f743d --- /dev/null +++ b/imports/client/views/nonOrg/app/module/navigation/index.js @@ -0,0 +1,7 @@ +import { composeWithTracker } from 'react-komposer'; +import { Meteor } from 'meteor/meteor'; +import AppNavigation from '../components/AppNavigation.js'; + +const composer = (props, onData) => onData(null, { hasUser: Meteor.user() }); + +export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation); diff --git a/imports/server/emails/verifyEmail.js b/imports/server/emails/verifyEmail.js index 7ef8755..9b74343 100644 --- a/imports/server/emails/verifyEmail.js +++ b/imports/server/emails/verifyEmail.js @@ -16,7 +16,6 @@ Accounts.emailTemplates.verifyEmail = { }else{ const name = user.profile.firstName; } - const name = user.firstName; const theUrl = Meteor.absoluteUrl(`back/verifyEmail/${_.last(url.split('/'))}`); return (