Fix admin/user login issues
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
maxPasswordTokenAgeInHours: 3,
|
maxPasswordTokenAgeInHours: 3,
|
||||||
sendEmailDelayInSeconds: 3,
|
sendEmailDelayInSeconds: 3,
|
||||||
supportEmail: 'support@kss.us.com',
|
supportEmail: 'support@kss.us.com',
|
||||||
sendEmail: true
|
sendEmail: true,
|
||||||
|
appName: "Deighton AR Test",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
maxPasswordTokenAgeInHours: 3,
|
maxPasswordTokenAgeInHours: 3,
|
||||||
sendEmailDelayInSeconds: 3,
|
sendEmailDelayInSeconds: 3,
|
||||||
supportEmail: 'support@kss.us.com',
|
supportEmail: 'support@kss.us.com',
|
||||||
sendEmail: true
|
sendEmail: true,
|
||||||
|
appName: "Deighton AR",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,22 +8,7 @@ import config from "config"
|
|||||||
import autobind from "autobind-decorator"
|
import autobind from "autobind-decorator"
|
||||||
import { PassThrough } from "stream"
|
import { PassThrough } from "stream"
|
||||||
import { catchAll } from "."
|
import { catchAll } from "."
|
||||||
|
import { pipeToPromise } from "../../util"
|
||||||
function pipeToGridFS(readable, writeable) {
|
|
||||||
const promise = new Promise((resolve, reject) => {
|
|
||||||
readable.on("error", (error) => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
writeable.on("error", (error) => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
writeable.on("finish", (file) => {
|
|
||||||
resolve(file)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
readable.pipe(writeable)
|
|
||||||
return promise
|
|
||||||
}
|
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
export class AssetRoutes {
|
export class AssetRoutes {
|
||||||
@@ -109,7 +94,7 @@ export class AssetRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async beginAssetUpload(req, res, next) {
|
async beginAssetUpload(req, res, next) {
|
||||||
const uploadId = this.db.newObjectId()
|
const uploadId = this.db.newObjectId().toString()
|
||||||
let {
|
let {
|
||||||
fileName,
|
fileName,
|
||||||
uploadSize,
|
uploadSize,
|
||||||
@@ -224,12 +209,12 @@ export class AssetRoutes {
|
|||||||
if (uploadedChunks >= uploadData.numberOfChunks) {
|
if (uploadedChunks >= uploadData.numberOfChunks) {
|
||||||
let readable = redisReadStream(this.rs.client, uploadDataId)
|
let readable = redisReadStream(this.rs.client, uploadDataId)
|
||||||
let writeable = this.db.gridfs.openUploadStreamWithId(
|
let writeable = this.db.gridfs.openUploadStreamWithId(
|
||||||
uploadId,
|
this.db.newObjectId(uploadId),
|
||||||
uploadData.fileName,
|
uploadData.fileName,
|
||||||
{ contentType: uploadData.contentType }
|
{ contentType: uploadData.contentType }
|
||||||
)
|
)
|
||||||
|
|
||||||
const file = await pipeToGridFS(readable, writeable)
|
const file = await pipeToPromise(readable, writeable)
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.rs.del(uploadId),
|
this.rs.del(uploadId),
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ export class AuthRoutes {
|
|||||||
this.sendEmailDelayInSeconds = config.get("email.sendEmailDelayInSeconds")
|
this.sendEmailDelayInSeconds = config.get("email.sendEmailDelayInSeconds")
|
||||||
this.supportEmail = config.get("email.supportEmail")
|
this.supportEmail = config.get("email.supportEmail")
|
||||||
this.sendEmail = config.get("email.sendEmail")
|
this.sendEmail = config.get("email.sendEmail")
|
||||||
|
this.appName = config.get("email.appName")
|
||||||
|
this.emailServiceName = config.get("serviceName.email")
|
||||||
app
|
app
|
||||||
.route("/auth/login")
|
.route("/auth/login")
|
||||||
// Used to login. Email must be confirmed.
|
// Used to login. Email must be confirmed.
|
||||||
@@ -208,11 +210,12 @@ export class AuthRoutes {
|
|||||||
siteUrl.host
|
siteUrl.host
|
||||||
}/confirm-email?email-token%3D${savedUser.emailToken.value}`,
|
}/confirm-email?email-token%3D${savedUser.emailToken.value}`,
|
||||||
supportEmail: this.supportEmail,
|
supportEmail: this.supportEmail,
|
||||||
|
appName: this.appName,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msgs)
|
await this.mq.request(this.emailServiceName, "sendEmail", msgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({})
|
res.json({})
|
||||||
@@ -393,10 +396,11 @@ export class AuthRoutes {
|
|||||||
siteUrl.host
|
siteUrl.host
|
||||||
}/reset-password?password-token%3D${savedUser.passwordToken.value}`,
|
}/reset-password?password-token%3D${savedUser.passwordToken.value}`,
|
||||||
supportEmail: this.supportEmail,
|
supportEmail: this.supportEmail,
|
||||||
|
appName: this.appName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msg)
|
await this.mq.request(this.emailServiceName, "sendEmail", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({})
|
res.json({})
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ export class UserRoutes {
|
|||||||
this.ws = container.ws
|
this.ws = container.ws
|
||||||
this.maxEmailTokenAgeInHours = config.get("email.maxEmailTokenAgeInHours")
|
this.maxEmailTokenAgeInHours = config.get("email.maxEmailTokenAgeInHours")
|
||||||
this.sendEmail = config.get("email.sendEmail")
|
this.sendEmail = config.get("email.sendEmail")
|
||||||
|
this.emailServiceName = config.get("serviceName.email")
|
||||||
|
|
||||||
app
|
app
|
||||||
.route("/users")
|
.route("/users")
|
||||||
.get(
|
.get(
|
||||||
@@ -164,7 +166,7 @@ export class UserRoutes {
|
|||||||
res.json(savedUser.toClient())
|
res.json(savedUser.toClient())
|
||||||
|
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msg)
|
await this.mq.request(this.emailServiceName, "sendEmail", msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +246,7 @@ export class UserRoutes {
|
|||||||
res.json({})
|
res.json({})
|
||||||
|
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msg)
|
await this.mq.request(this.emailServiceName, "sendEmail", msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
39
server/src/util.js
Normal file
39
server/src/util.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import stream from "stream"
|
||||||
|
|
||||||
|
export function streamToBuffer(readable) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var chunks = []
|
||||||
|
var writeable = new stream.Writable()
|
||||||
|
|
||||||
|
writeable._write = function(chunk, enc, done) {
|
||||||
|
chunks.push(chunk)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
|
||||||
|
readable.on("end", function() {
|
||||||
|
resolve(Buffer.concat(chunks))
|
||||||
|
})
|
||||||
|
|
||||||
|
readable.on("error", (err) => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
|
||||||
|
readable.pipe(writeable)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pipeToPromise(readable, writeable) {
|
||||||
|
const promise = new Promise((resolve, reject) => {
|
||||||
|
readable.on("error", (error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
writeable.on("error", (error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
writeable.on("finish", (file) => {
|
||||||
|
resolve(file)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
readable.pipe(writeable)
|
||||||
|
return promise
|
||||||
|
}
|
||||||
@@ -52,12 +52,12 @@ class API extends EventEmitter {
|
|||||||
localStorage.removeItem(authTokenKeyName)
|
localStorage.removeItem(authTokenKeyName)
|
||||||
sessionStorage.removeItem(authTokenKeyName)
|
sessionStorage.removeItem(authTokenKeyName)
|
||||||
this._token = null
|
this._token = null
|
||||||
this._user = {}
|
this._user = { loggedOut: true }
|
||||||
this.socket = null
|
this.socket = null
|
||||||
this.emit("logout")
|
this.emit("logout")
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this._user = {}
|
this._user = { loggedOut: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ class API extends EventEmitter {
|
|||||||
localStorage.removeItem(authTokenKeyName)
|
localStorage.removeItem(authTokenKeyName)
|
||||||
sessionStorage.removeItem(authTokenKeyName)
|
sessionStorage.removeItem(authTokenKeyName)
|
||||||
this._token = null
|
this._token = null
|
||||||
this._user = {}
|
this._user = { loggedOut: true }
|
||||||
this.disconnectSocket()
|
this.disconnectSocket()
|
||||||
this.emit("logout")
|
this.emit("logout")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { Component } from "react"
|
|||||||
import {
|
import {
|
||||||
Login,
|
Login,
|
||||||
Logout,
|
Logout,
|
||||||
|
Parking,
|
||||||
ResetPassword,
|
ResetPassword,
|
||||||
ForgotPassword,
|
ForgotPassword,
|
||||||
ConfirmEmail,
|
ConfirmEmail,
|
||||||
@@ -29,18 +30,38 @@ export class App extends Component {
|
|||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Column minHeight="100vh">
|
<Column minHeight="100vh">
|
||||||
<Route
|
<Route
|
||||||
path="/app"
|
path="/admin"
|
||||||
render={(props) => (
|
render={(props) => (
|
||||||
<Column.Item height={sizeInfo.headerHeight}>
|
<Column.Item height={sizeInfo.headerHeight}>
|
||||||
<Header
|
<Header
|
||||||
{...props}
|
{...props}
|
||||||
left={[
|
left={[
|
||||||
{ image: require("images/badge.png"), path: "/app/home" },
|
{ image: require("images/badge.png"), path: "/admin/home" },
|
||||||
{ text: "Teams", path: "/app/teams" },
|
{ text: "Teams", path: "/admin/teams" },
|
||||||
{ text: "Users", path: "/app/users" },
|
{ text: "Users", path: "/admin/users" },
|
||||||
]}
|
]}
|
||||||
right={[
|
right={[
|
||||||
{ icon: "profile", path: "/app/profile" },
|
{ icon: "profile", path: "/admin/profile" },
|
||||||
|
{ icon: "logout", path: "/logout" },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Column.Item>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/user"
|
||||||
|
render={(props) => (
|
||||||
|
<Column.Item height={sizeInfo.headerHeight}>
|
||||||
|
<Header
|
||||||
|
{...props}
|
||||||
|
left={[
|
||||||
|
{
|
||||||
|
image: require("images/badge.png"),
|
||||||
|
path: "/user/profile",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
right={[
|
||||||
|
{ icon: "profile", path: "/user/profile" },
|
||||||
{ icon: "logout", path: "/logout" },
|
{ icon: "logout", path: "/logout" },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -50,18 +71,30 @@ export class App extends Component {
|
|||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/login" component={Login} />
|
<Route exact path="/login" component={Login} />
|
||||||
<Route exact path="/logout" component={Logout} />
|
<Route exact path="/logout" component={Logout} />
|
||||||
|
<Route exact path="/parking" component={Parking} />
|
||||||
<Route exact path="/confirm-email" component={ConfirmEmail} />
|
<Route exact path="/confirm-email" component={ConfirmEmail} />
|
||||||
<Route exact path="/reset-password" component={ResetPassword} />
|
<Route exact path="/reset-password" component={ResetPassword} />
|
||||||
<Route exact path="/forgot-password" component={ForgotPassword} />
|
<Route exact path="/forgot-password" component={ForgotPassword} />
|
||||||
<ProtectedRoute exact path="/app/profile" component={Profile} />
|
<ProtectedRoute exact path="/user/profile" component={Profile} />
|
||||||
<ProtectedRoute exact admin path="/app/home" component={Home} />
|
<ProtectedRoute
|
||||||
<ProtectedRoute exact admin path="/app/teams" component={Teams} />
|
exact
|
||||||
<ProtectedRoute exact admin path="/app/system" component={System} />
|
admin
|
||||||
<ProtectedRoute exact admin path="/app/users" component={Users} />
|
path="/admin/profile"
|
||||||
<DefaultRoute redirect="/app/home" />
|
component={Profile}
|
||||||
|
/>
|
||||||
|
<ProtectedRoute exact admin path="/admin/home" component={Home} />
|
||||||
|
<ProtectedRoute exact admin path="/admin/teams" component={Teams} />
|
||||||
|
<ProtectedRoute
|
||||||
|
exact
|
||||||
|
admin
|
||||||
|
path="/admin/system"
|
||||||
|
component={System}
|
||||||
|
/>
|
||||||
|
<ProtectedRoute exact admin path="/admin/users" component={Users} />
|
||||||
|
<DefaultRoute user="/user/profile" admin="/admin/home" />
|
||||||
</Switch>
|
</Switch>
|
||||||
<Route
|
<Route
|
||||||
path="/app"
|
path="/(user|admin)"
|
||||||
render={() => (
|
render={() => (
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<Footer
|
<Footer
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export class ConfirmEmail extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,49 @@
|
|||||||
import React, { Component } from "react"
|
import React, { Component } from "react"
|
||||||
import { Route, Redirect } from "react-router-dom"
|
import { Route, Redirect } from "react-router-dom"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
import { api } from "src/API"
|
||||||
|
|
||||||
export class DefaultRoute extends Component {
|
export class DefaultRoute extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
redirect: PropTypes.string,
|
location: PropTypes.shape({
|
||||||
|
pathname: PropTypes.string,
|
||||||
|
search: PropTypes.string,
|
||||||
|
}),
|
||||||
|
user: PropTypes.string.isRequired,
|
||||||
|
admin: PropTypes.string.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// NOTE: When working on the site, Redirect to the page you are working on
|
const user = api.loggedInUser
|
||||||
return <Route render={() => <Redirect to={this.props.redirect} />} />
|
|
||||||
|
if (user.loggedOut) {
|
||||||
|
return <Route render={() => <Redirect to="/login" />} />
|
||||||
|
} else if (user.pending) {
|
||||||
|
// If login token has not yet been confirmed, park until it is then come back here
|
||||||
|
return (
|
||||||
|
<Route
|
||||||
|
render={() => (
|
||||||
|
<Redirect
|
||||||
|
to={`/parking?redirect=${this.props.location.pathname}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// Render a redirect to the user or admin default page
|
||||||
|
return (
|
||||||
|
<Route
|
||||||
|
render={() => (
|
||||||
|
<Redirect
|
||||||
|
to={
|
||||||
|
user._id && user.administrator
|
||||||
|
? this.props.admin
|
||||||
|
: this.props.user
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ export class ForgotPassword extends Component {
|
|||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item grow>
|
<Column.Item grow>
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ export class Login extends Component {
|
|||||||
this.setState({ waitModal: false })
|
this.setState({ waitModal: false })
|
||||||
if (this.props.history) {
|
if (this.props.history) {
|
||||||
let url =
|
let url =
|
||||||
new URLSearchParams(window.location.search).get("redirect") || "/"
|
new URLSearchParams(this.props.history.location.search).get(
|
||||||
|
"redirect"
|
||||||
|
) || "/"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.props.history.replace(url)
|
this.props.history.replace(url)
|
||||||
@@ -224,7 +226,7 @@ export class Login extends Component {
|
|||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item grow>
|
<Column.Item grow>
|
||||||
<WaitModal active={waitModal} message="Logging in..." />
|
<WaitModal open={waitModal} message="Logging in..." />
|
||||||
<MessageModal
|
<MessageModal
|
||||||
error
|
error
|
||||||
open={!!messageModal}
|
open={!!messageModal}
|
||||||
|
|||||||
53
website/src/Auth/Parking.js
Normal file
53
website/src/Auth/Parking.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import React, { Component, Fragment } from "react"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
import { api } from "src/API"
|
||||||
|
import { WaitModal } from "../Modal"
|
||||||
|
import { Column } from "ui"
|
||||||
|
import autobind from "autobind-decorator"
|
||||||
|
|
||||||
|
export class Parking extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
history: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
api.addListener("login", this.goToRedirect)
|
||||||
|
api.addListener("logout", this.goToLogin)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
api.removeListener("login", this.goToRedirect)
|
||||||
|
api.removeListener("logout", this.goToLogin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
goToRedirect() {
|
||||||
|
if (this.props.history) {
|
||||||
|
let url =
|
||||||
|
new URLSearchParams(this.props.history.location.search).get(
|
||||||
|
"redirect"
|
||||||
|
) || "/"
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.props.history.replace(url)
|
||||||
|
} catch (error) {
|
||||||
|
this.props.history.replace("/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
goToLogin() {
|
||||||
|
this.props.history.replace("/login")
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<Column.Item grow>
|
||||||
|
<WaitModal open loader={false} message="Authenticating..." />
|
||||||
|
</Column.Item>
|
||||||
|
</Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import React from 'react'
|
import React from "react"
|
||||||
import { Route, Redirect } from 'react-router'
|
import { Route, Redirect } from "react-router"
|
||||||
import { PropTypes } from 'prop-types'
|
import { PropTypes } from "prop-types"
|
||||||
import { api } from 'src/API'
|
import { api } from "src/API"
|
||||||
import autobind from 'autobind-decorator'
|
|
||||||
|
|
||||||
export class ProtectedRoute extends React.Component {
|
export class ProtectedRoute extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -13,33 +12,32 @@ export class ProtectedRoute extends React.Component {
|
|||||||
admin: PropTypes.bool,
|
admin: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
updateComponent() {
|
|
||||||
this.forceUpdate()
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
api.addListener("login", this.updateComponent)
|
|
||||||
api.addListener("logout", this.updateComponent)
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
api.removeListener("login", this.updateComponent)
|
|
||||||
api.removeListener("logout", this.updateComponent)
|
|
||||||
}
|
|
||||||
|
|
||||||
render(props) {
|
render(props) {
|
||||||
const user = api.loggedInUser
|
const user = api.loggedInUser
|
||||||
|
|
||||||
if (user.pending) {
|
if (user.pending) {
|
||||||
return null
|
// If login token has not yet been confirmed, park until it is and redirect back here
|
||||||
|
return (
|
||||||
|
<Route
|
||||||
|
render={() => (
|
||||||
|
<Redirect
|
||||||
|
to={`/parking?redirect=${this.props.location.pathname}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
|
// If we are not a user or an admin go to the login page
|
||||||
if (!user._id || (this.props.admin && !user.administrator)) {
|
if (!user._id || (this.props.admin && !user.administrator)) {
|
||||||
return (
|
return (
|
||||||
<Redirect
|
<Route
|
||||||
to={`/login?redirect=${this.props.location.pathname}${
|
render={() => (
|
||||||
this.props.location.search
|
<Redirect
|
||||||
}`}
|
to={`/login?redirect=${this.props.location.pathname}${
|
||||||
|
this.props.location.search
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ export class ResetPassword extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
export { Login } from './Login'
|
export { Login } from "./Login"
|
||||||
export { Logout } from './Logout'
|
export { Logout } from "./Logout"
|
||||||
export { ResetPassword } from './ResetPassword'
|
export { Parking } from "./Parking"
|
||||||
export { ForgotPassword } from './ForgotPassword'
|
export { ResetPassword } from "./ResetPassword"
|
||||||
export { ConfirmEmail } from './ConfirmEmail'
|
export { ForgotPassword } from "./ForgotPassword"
|
||||||
export { DefaultRoute } from './DefaultRoute'
|
export { ConfirmEmail } from "./ConfirmEmail"
|
||||||
export { ProtectedRoute } from './ProtectedRoute'
|
export { DefaultRoute } from "./DefaultRoute"
|
||||||
|
export { ProtectedRoute } from "./ProtectedRoute"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class Home extends Component {
|
|||||||
<PanelButton
|
<PanelButton
|
||||||
icon="users"
|
icon="users"
|
||||||
text="Users"
|
text="Users"
|
||||||
onClick={() => this.props.history.push("/app/users")}
|
onClick={() => this.props.history.push("/admin/users")}
|
||||||
/>
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
||||||
@@ -27,7 +27,7 @@ export class Home extends Component {
|
|||||||
<PanelButton
|
<PanelButton
|
||||||
icon="teams"
|
icon="teams"
|
||||||
text="Teams"
|
text="Teams"
|
||||||
onClick={() => this.props.history.push("/app/teams")}
|
onClick={() => this.props.history.push("/admin/teams")}
|
||||||
/>
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
||||||
@@ -35,7 +35,7 @@ export class Home extends Component {
|
|||||||
<PanelButton
|
<PanelButton
|
||||||
icon="system"
|
icon="system"
|
||||||
text="System"
|
text="System"
|
||||||
onClick={() => this.props.history.push("/app/system")}
|
onClick={() => this.props.history.push("/admin/system")}
|
||||||
/>
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ export class MasterDetail extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export class MasterList extends React.Component {
|
|||||||
<List.Item
|
<List.Item
|
||||||
key={item._id || "0"}
|
key={item._id || "0"}
|
||||||
onClick={(e) => this.props.onItemListClick(e, index)}
|
onClick={(e) => this.props.onItemListClick(e, index)}
|
||||||
active={item === this.props.selectedItem}>
|
open={item === this.props.selectedItem}>
|
||||||
<List.Icon name={data.icon} size={sizeInfo.listIcon} />
|
<List.Icon name={data.icon} size={sizeInfo.listIcon} />
|
||||||
<List.Text>{data.text}</List.Text>
|
<List.Text>{data.text}</List.Text>
|
||||||
{item === selectedItem && selectionModified ? (
|
{item === selectedItem && selectionModified ? (
|
||||||
|
|||||||
@@ -4,17 +4,26 @@ import { Dimmer, Loader, Text } from 'ui'
|
|||||||
|
|
||||||
export class WaitModal extends React.Component {
|
export class WaitModal extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
active: PropTypes.bool.isRequired,
|
open: PropTypes.bool.isRequired,
|
||||||
message: PropTypes.string,
|
message: PropTypes.string,
|
||||||
|
loader: PropTypes.bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
loader: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { active, message } = this.props
|
const { open, message, loader } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dimmer active={active}>
|
<Dimmer active={open}>
|
||||||
<Loader />
|
{loader && <Loader />}
|
||||||
{message && <Text size='huge' color='inverse'>{message}</Text>}
|
{message && (
|
||||||
|
<Text size="huge" color="inverse">
|
||||||
|
{message}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Dimmer>
|
</Dimmer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export class Profile extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export class System extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
|
|||||||
Reference in New Issue
Block a user