Remove whitespace around email when logging in
This commit is contained in:
@@ -6,3 +6,5 @@ VERSION=$(cat $SCRIPT_DIR/../../scratch/version.txt)
|
|||||||
NEW_APK=$(dirname $OLD_APK)/deighton-ar-${VERSION}.apk
|
NEW_APK=$(dirname $OLD_APK)/deighton-ar-${VERSION}.apk
|
||||||
|
|
||||||
mv $OLD_APK $NEW_APK
|
mv $OLD_APK $NEW_APK
|
||||||
|
|
||||||
|
echo $NEW_APK
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-native start",
|
"start": "react-native start",
|
||||||
"android": "react-native run-android",
|
"android": "react-native run-android",
|
||||||
"android:release": "cd android; rm -rf ./app/build && ./gradlew assembleRelease",
|
"android:release": "cd android; rm -rf ./app/build && ./gradlew assembleRelease && ./rename-apk",
|
||||||
"ios": "react-native run-ios",
|
"ios": "react-native run-ios",
|
||||||
"test": "node node_modules/jest/bin/jest.js",
|
"test": "node node_modules/jest/bin/jest.js",
|
||||||
"postinstall": "sed -i '' 's/#import <RCTAnimation\\/RCTValueAnimatedNode.h>/#import \"RCTValueAnimatedNode.h\"/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h; sed -i '' 's/#import <fishhook\\/fishhook.h>/#import \"fishhook.h\"/' ./node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m"
|
"postinstall": "sed -i '' 's/#import <RCTAnimation\\/RCTValueAnimatedNode.h>/#import \"RCTValueAnimatedNode.h\"/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h; sed -i '' 's/#import <fishhook\\/fishhook.h>/#import \"fishhook.h\"/' ./node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m"
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export class Login extends React.Component {
|
|||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
api
|
api
|
||||||
.login(obj.email, obj.password, obj.rememberMe)
|
.login(obj.email.trim(), obj.password, obj.rememberMe)
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
history.replace("/home")
|
history.replace("/home")
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const localIPAddr = "192.168.1.175"
|
export const localIPAddr = "192.168.1.175"
|
||||||
export const defaultUser = "john@lyon-smith.org"
|
//export const defaultUser = "john@lyon-smith.org"
|
||||||
//export const defaultUser = ""
|
export const defaultUser = ""
|
||||||
// export const minGPSAccuracy = 20
|
// export const minGPSAccuracy = 20
|
||||||
export const minGPSAccuracy = 100
|
export const minGPSAccuracy = 100
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"start": "babel-node src/server.js",
|
"start": "babel-node src/server.js",
|
||||||
"start:prod": "NODE_ENV=production node dist/server.js",
|
"start:prod": "NODE_ENV=production node dist/server.js",
|
||||||
"build": "rm -rf dist && babel src -d dist -s",
|
"build": "rm -rf dist && babel src -d dist -s",
|
||||||
"deploy": "rsync -vr -e ssh --exclude-from .rsync-exclude * ubuntu@tmr:deighton-ar/server/ && ssh ubuntu@tmr 'cd deighton-ar/server && npm install'",
|
"deploy": "rsync -vr -e ssh --exclude-from .rsync-exclude * ubuntu@gs-1:deighton-ar/server/ && ssh ubuntu@gs-1 'cd deighton-ar/server && npm install'",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"actor:api": "monzilla 'src/api/**/*.js:src/database/**/*.js' -- babel-node src/api/index.js",
|
"actor:api": "monzilla 'src/api/**/*.js:src/database/**/*.js' -- babel-node src/api/index.js",
|
||||||
"actor:api:debug": "babel-node --inspect-brk src/api/index.js",
|
"actor:api:debug": "babel-node --inspect-brk src/api/index.js",
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export class AuthRoutes {
|
|||||||
res.set("Authorization", `Bearer ${savedUser.loginToken}`)
|
res.set("Authorization", `Bearer ${savedUser.loginToken}`)
|
||||||
res.json(savedUser.toClient())
|
res.json(savedUser.toClient())
|
||||||
} else {
|
} else {
|
||||||
throw createError.BadRequest("email or password incorrect")
|
throw createError.BadRequest("Email or password incorrect")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node scripts/start.js",
|
"start": "node scripts/start.js",
|
||||||
"build": "node scripts/build.js",
|
"build": "node scripts/build.js",
|
||||||
"deploy": "rsync -vr -e ssh build/* ubuntu@tmr:deighton-ar/website/",
|
"deploy": "rsync -vr -e ssh build/* ubuntu@gs-1:deighton-ar/website/",
|
||||||
"lint": "eslint --ext .js --ext .jsx src/",
|
"lint": "eslint --ext .js --ext .jsx src/",
|
||||||
"lint:fix": "eslint --ext .js --ext .jsx --fix src/"
|
"lint:fix": "eslint --ext .js --ext .jsx --fix src/"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,37 +1,47 @@
|
|||||||
import React, { Component, Fragment } from 'react'
|
import React, { Component, Fragment } from "react"
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from "prop-types"
|
||||||
import { regExpPattern } from 'regexp-pattern'
|
import { regExpPattern } from "regexp-pattern"
|
||||||
import { api } from 'src/API'
|
import { api } from "src/API"
|
||||||
import { WaitModal, MessageModal } from '../Modal'
|
import { WaitModal, MessageModal } from "../Modal"
|
||||||
import { Box, Image, Link, Text, Row, Column, BoundInput, BoundCheckbox, BoundButton } from 'ui'
|
import {
|
||||||
import headerLogo from 'images/deighton.png'
|
Box,
|
||||||
import { versionInfo } from '../version'
|
Image,
|
||||||
import { FormBinder } from 'react-form-binder'
|
Link,
|
||||||
import autobind from 'autobind-decorator'
|
Text,
|
||||||
import { sizeInfo, colorInfo } from 'ui/style'
|
Row,
|
||||||
|
Column,
|
||||||
|
BoundInput,
|
||||||
|
BoundCheckbox,
|
||||||
|
BoundButton,
|
||||||
|
} from "ui"
|
||||||
|
import headerLogo from "images/deighton.png"
|
||||||
|
import { versionInfo } from "../version"
|
||||||
|
import { FormBinder } from "react-form-binder"
|
||||||
|
import autobind from "autobind-decorator"
|
||||||
|
import { sizeInfo, colorInfo } from "ui/style"
|
||||||
|
|
||||||
export class Login extends Component {
|
export class Login extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
history: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
|
history: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
||||||
}
|
}
|
||||||
|
|
||||||
static bindings = {
|
static bindings = {
|
||||||
email: {
|
email: {
|
||||||
alwaysGet: true,
|
alwaysGet: true,
|
||||||
isValid: (r, v) => (regExpPattern.email.test(v))
|
isValid: (r, v) => regExpPattern.email.test(v),
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
alwaysGet: true,
|
alwaysGet: true,
|
||||||
isValid: (r, v) => (v !== '')
|
isValid: (r, v) => v !== "",
|
||||||
},
|
},
|
||||||
rememberMe: {
|
rememberMe: {
|
||||||
alwaysGet: true,
|
alwaysGet: true,
|
||||||
initValue: true
|
initValue: true,
|
||||||
},
|
},
|
||||||
submit: {
|
submit: {
|
||||||
noValue: true,
|
noValue: true,
|
||||||
isDisabled: (r) => (!r.anyModified || !r.allValid)
|
isDisabled: (r) => !r.anyModified || !r.allValid,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -39,7 +49,7 @@ export class Login extends Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
waitModal: false,
|
waitModal: false,
|
||||||
messageModal: null,
|
messageModal: null,
|
||||||
binder: new FormBinder({}, Login.bindings)
|
binder: new FormBinder({}, Login.bindings),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,23 +69,31 @@ export class Login extends Component {
|
|||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
this.setState({ waitModal: true })
|
this.setState({ waitModal: true })
|
||||||
api.login(obj.email, obj.password, obj.rememberMe).then((user) => {
|
api
|
||||||
this.setState({ waitModal: false })
|
.login(obj.email.trim(), obj.password, obj.rememberMe)
|
||||||
if (this.props.history) {
|
.then((user) => {
|
||||||
let url = new URLSearchParams(window.location.search).get('redirect') || '/'
|
this.setState({ waitModal: false })
|
||||||
|
if (this.props.history) {
|
||||||
|
let url =
|
||||||
|
new URLSearchParams(window.location.search).get("redirect") || "/"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.props.history.replace(url)
|
this.props.history.replace(url)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.props.history.replace('/')
|
this.props.history.replace("/")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}).catch((error) => {
|
|
||||||
this.setState({
|
|
||||||
waitModal: false,
|
|
||||||
messageModal: { icon: 'hand', message: `Unable to login`, detail: error.message }
|
|
||||||
})
|
})
|
||||||
})
|
.catch((error) => {
|
||||||
|
this.setState({
|
||||||
|
waitModal: false,
|
||||||
|
messageModal: {
|
||||||
|
icon: "hand",
|
||||||
|
message: `Unable to login`,
|
||||||
|
detail: error.message,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,10 +101,13 @@ export class Login extends Component {
|
|||||||
handleMessageModalDismiss() {
|
handleMessageModalDismiss() {
|
||||||
this.setState({
|
this.setState({
|
||||||
messageModal: null,
|
messageModal: null,
|
||||||
binder: new FormBinder({ email: this.state.binder.getFieldValue('email') }, Login.bindings)
|
binder: new FormBinder(
|
||||||
|
{ email: this.state.binder.getFieldValue("email") },
|
||||||
|
Login.bindings
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
const elems = document.getElementsByName('password')
|
const elems = document.getElementsByName("password")
|
||||||
|
|
||||||
if (elems) {
|
if (elems) {
|
||||||
elems[0].focus()
|
elems[0].focus()
|
||||||
@@ -103,8 +124,13 @@ export class Login extends Component {
|
|||||||
<Row>
|
<Row>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
<Row.Item width={sizeInfo.modalWidth}>
|
<Row.Item width={sizeInfo.modalWidth}>
|
||||||
<form onSubmit={this.handleSubmit} id='loginForm'>
|
<form onSubmit={this.handleSubmit} id="loginForm">
|
||||||
<Box border={{ width: sizeInfo.headerBorderWidth, color: colorInfo.headerBorder }} radius={sizeInfo.formBoxRadius}>
|
<Box
|
||||||
|
border={{
|
||||||
|
width: sizeInfo.headerBorderWidth,
|
||||||
|
color: colorInfo.headerBorder,
|
||||||
|
}}
|
||||||
|
radius={sizeInfo.formBoxRadius}>
|
||||||
<Row>
|
<Row>
|
||||||
<Row.Item width={sizeInfo.formRowSpacing} />
|
<Row.Item width={sizeInfo.formRowSpacing} />
|
||||||
<Row.Item>
|
<Row.Item>
|
||||||
@@ -114,33 +140,51 @@ export class Login extends Component {
|
|||||||
<Row>
|
<Row>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
<Row.Item>
|
<Row.Item>
|
||||||
<Image source={headerLogo} width={sizeInfo.loginLogoWidth} />
|
<Image
|
||||||
|
source={headerLogo}
|
||||||
|
width={sizeInfo.loginLogoWidth}
|
||||||
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item height={sizeInfo.formColumnSpacing} />
|
<Column.Item height={sizeInfo.formColumnSpacing} />
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<Text size='large'>Login</Text>
|
<Text size="large">Login</Text>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item height={sizeInfo.formColumnSpacing} />
|
<Column.Item height={sizeInfo.formColumnSpacing} />
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<BoundInput label='Email' name='email'
|
<BoundInput
|
||||||
placeholder='example@xyz.com' binder={this.state.binder}
|
label="Email"
|
||||||
message='Enter the email address associated with your account.' />
|
name="email"
|
||||||
|
placeholder="example@xyz.com"
|
||||||
|
binder={this.state.binder}
|
||||||
|
message="Enter the email address associated with your account."
|
||||||
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<BoundInput password label='Password' name='password'
|
<BoundInput
|
||||||
binder={this.state.binder} message='Enter your password.' />
|
password
|
||||||
|
label="Password"
|
||||||
|
name="password"
|
||||||
|
binder={this.state.binder}
|
||||||
|
message="Enter your password."
|
||||||
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<Row>
|
<Row>
|
||||||
<Row.Item>
|
<Row.Item>
|
||||||
<Link to='/forgot-password'>Forgot your password?</Link>
|
<Link to="/forgot-password">
|
||||||
|
Forgot your password?
|
||||||
|
</Link>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
<Row.Item>
|
<Row.Item>
|
||||||
<BoundCheckbox label='Remember Me' name='rememberMe' binder={this.state.binder} />
|
<BoundCheckbox
|
||||||
|
label="Remember Me"
|
||||||
|
name="rememberMe"
|
||||||
|
binder={this.state.binder}
|
||||||
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
@@ -149,14 +193,23 @@ export class Login extends Component {
|
|||||||
<Row>
|
<Row>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
<Row.Item>
|
<Row.Item>
|
||||||
<BoundButton name='submit' text='Login' submit='loginForm' binder={this.state.binder} />
|
<BoundButton
|
||||||
|
name="submit"
|
||||||
|
text="Login"
|
||||||
|
submit="loginForm"
|
||||||
|
binder={this.state.binder}
|
||||||
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item height={sizeInfo.formColumnSpacing} />
|
<Column.Item height={sizeInfo.formColumnSpacing} />
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<Text>
|
<Text>
|
||||||
Please contact <Link to={`mailto:${versionInfo.supportEmail}`}>{versionInfo.supportEmail}</Link> to request login credentials.
|
Please contact{" "}
|
||||||
|
<Link to={`mailto:${versionInfo.supportEmail}`}>
|
||||||
|
{versionInfo.supportEmail}
|
||||||
|
</Link>{" "}
|
||||||
|
to request login credentials.
|
||||||
</Text>
|
</Text>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item height={sizeInfo.formColumnSpacing} />
|
<Column.Item height={sizeInfo.formColumnSpacing} />
|
||||||
@@ -171,12 +224,15 @@ export class Login extends Component {
|
|||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item grow>
|
<Column.Item grow>
|
||||||
<WaitModal active={waitModal} message='Logging in...' />
|
<WaitModal active={waitModal} message="Logging in..." />
|
||||||
<MessageModal error open={!!messageModal}
|
<MessageModal
|
||||||
icon={messageModal ? messageModal.icon : ''}
|
error
|
||||||
message={messageModal ? messageModal.message : ''}
|
open={!!messageModal}
|
||||||
detail={messageModal ? messageModal.detail : ''}
|
icon={messageModal ? messageModal.icon : ""}
|
||||||
onDismiss={this.handleMessageModalDismiss} />
|
message={messageModal ? messageModal.message : ""}
|
||||||
|
detail={messageModal ? messageModal.detail : ""}
|
||||||
|
onDismiss={this.handleMessageModalDismiss}
|
||||||
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user