diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c5ec0d6bf..dbfdfb175 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,5 +5,3 @@ - click a button - view the cat - see the cat meow - -@coralproject/tech diff --git a/.gitignore b/.gitignore index eff774450..3b59ff2f5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/coral-admin/bundle.js *.iml .env gaba.cfg +.idea/ diff --git a/app.js b/app.js index 6512680aa..8008cb01e 100644 --- a/app.js +++ b/app.js @@ -21,7 +21,7 @@ if (app.get('env') !== 'test') { // APP MIDDLEWARE //============================================================================== -app.set('trust proxy', 'loopback'); +app.set('trust proxy', 1); app.use(helmet()); app.use(bodyParser.json()); app.use('/client', express.static(path.join(__dirname, 'dist'))); @@ -97,7 +97,7 @@ app.use('/api', (err, req, res, next) => { res.status(err.status || 500); res.json({ message: err.message, - error: app.get('env') === 'development' ? err : null + error: app.get('env') === 'development' ? err : {} }); }); @@ -109,7 +109,7 @@ app.use('/', (err, req, res, next) => { res.status(err.status || 500); res.render('error', { message: err.message, - error: app.get('env') === 'development' ? err : null + error: app.get('env') === 'development' ? err : {} }); }); diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 5d21fc819..6d55d7b18 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -1,14 +1,14 @@ import React from 'react'; import {Router, Route, IndexRoute, browserHistory} from 'react-router'; -import ModerationQueue from 'containers/ModerationQueue'; -import CommentStream from 'containers/CommentStream'; -import Configure from 'containers/Configure'; +import ModerationQueue from 'containers/ModerationQueue/ModerationQueue'; +import CommentStream from 'containers/CommentStream/CommentStream'; +import Configure from 'containers/Configure/Configure'; import CommunityContainer from 'containers/Community/CommunityContainer'; import LayoutContainer from 'containers/LayoutContainer'; const routes = ( - + diff --git a/client/coral-admin/src/actions/auth.js b/client/coral-admin/src/actions/auth.js new file mode 100644 index 000000000..c5a03132f --- /dev/null +++ b/client/coral-admin/src/actions/auth.js @@ -0,0 +1,19 @@ +import * as actions from '../constants/auth'; +import {base, handleResp, getInit} from '../helpers/response'; + +// Check Login + +const checkLoginRequest = () => ({type: actions.CHECK_LOGIN_REQUEST}); +const checkLoginSuccess = (user, isAdmin) => ({type: actions.CHECK_LOGIN_SUCCESS, user, isAdmin}); +const checkLoginFailure = error => ({type: actions.CHECK_LOGIN_FAILURE, error}); + +export const checkLogin = () => dispatch => { + dispatch(checkLoginRequest()); + fetch(`${base}/auth`, getInit('GET')) + .then(handleResp) + .then(user => { + const isAdmin = !!user.roles.filter(i => i === 'admin').length; + dispatch(checkLoginSuccess(user, isAdmin)); + }) + .catch(error => dispatch(checkLoginFailure(error))); +}; diff --git a/client/coral-admin/src/components/Comment.js b/client/coral-admin/src/components/Comment.js index 154d68134..7cba85788 100644 --- a/client/coral-admin/src/components/Comment.js +++ b/client/coral-admin/src/components/Comment.js @@ -1,11 +1,12 @@ import React from 'react'; -import {Button, Icon} from 'react-mdl'; import timeago from 'timeago.js'; import styles from './CommentList.css'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations.json'; import Linkify from 'react-linkify'; +import {FabButton} from 'coral-ui'; +import {Icon} from 'react-mdl'; const linkify = new Linkify(); @@ -14,7 +15,7 @@ export default props => { const links = linkify.getMatches(props.comment.get('body')); return ( -
  • +
  • person @@ -26,12 +27,12 @@ export default props => { {links ? Contains Link : null}
    - {props.actions.map(action => canShowAction(action, props.comment) ? ( - + /> ) : null)}
    diff --git a/client/coral-admin/src/components/CommentList.js b/client/coral-admin/src/components/CommentList.js index 819de62b0..e4682252d 100644 --- a/client/coral-admin/src/components/CommentList.js +++ b/client/coral-admin/src/components/CommentList.js @@ -112,15 +112,15 @@ export default class CommentList extends React.Component { } render () { - const {singleView, commentIds, comments, hideActive} = this.props; + const {singleView, commentIds, comments, hideActive, key} = this.props; const {active} = this.state; return ( -