Merge branch 'staging' into add-publish-endpoint

pull/23/head
Theodore Kluge 2018-11-12 15:41:32 -05:00 committed by GitHub
commit 73b74b8c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 55 additions and 53 deletions

View File

@ -15,4 +15,4 @@ deploy:
before_script:
- npm install
script: npm run lint && npm run custom-tests && echo 'Done.'
script: npm test

View File

@ -23,7 +23,7 @@ passport.serializeUser((user, next) => {
next(null, user.id)
})
passport.deserializeUser((id, next) => {
return User.findOne({id: id})
return User.findOne({ id: id })
.then((user) => {
next(null, user)
return user
@ -37,7 +37,7 @@ function PassportHelper () {
const strategies = sails.config.passport
for (const key in strategies) {
let options = {passReqToCallback: true}
let options = { passReqToCallback: true }
let Strategy = strategies[key].strategy
if (key === 'local') {
_.extend(options, {
@ -114,7 +114,7 @@ function PassportHelper () {
if (profile.emails && profile.emails[0]) { userAttrs.email = profile.emails[0].value }
if (!userAttrs.email) { return next(new Error('No email available')) }
const pass = await Passport.findOne({
const passport = await Passport.findOne({
provider,
identifier: q.identifier.toString()
})

42
app.js
View File

@ -20,35 +20,31 @@
* https://sailsjs.com/anatomy/app.js
*/
// Ensure we're in the project directory, so cwd-relative paths work as expected
// no matter where we actually lift from.
// > Note: This is not required in order to lift, but it is a convenient default.
process.chdir(__dirname);
process.chdir(__dirname)
// Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files).
var sails;
var rc;
var sails
var rc
try {
sails = require('sails');
rc = require('sails/accessible/rc');
sails = require('sails')
rc = require('sails/accessible/rc')
} catch (err) {
console.error('Encountered an error when attempting to require(\'sails\'):');
console.error(err.stack);
console.error('--');
console.error('To run an app using `node app.js`, you need to have Sails installed');
console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re');
console.error('in the same directory as your app and run `npm install`.');
console.error();
console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can');
console.error('also run this app with `sails lift`. Running with `sails lift` will');
console.error('not run this file (`app.js`), but it will do exactly the same thing.');
console.error('(It even uses your app directory\'s local Sails install, if possible.)');
return;
}//-•
console.error('Encountered an error when attempting to require(\'sails\'):')
console.error(err.stack)
console.error('--')
console.error('To run an app using `node app.js`, you need to have Sails installed')
console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re')
console.error('in the same directory as your app and run `npm install`.')
console.error()
console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can')
console.error('also run this app with `sails lift`. Running with `sails lift` will')
console.error('not run this file (`app.js`), but it will do exactly the same thing.')
console.error('(It even uses your app directory\'s local Sails install, if possible.)')
return
}// -•
// Start server
sails.lift(rc('sails'));
sails.lift(rc('sails'))

View File

@ -53,9 +53,9 @@ export const setLoggedIn = (data) => (dispatch, getState) => {
export const checkEmail = email => async (dispatch, getState) => {
dispatch(setWorking(true))
dispatch(clearError())
if (/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
if (/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
try {
const res = await Ajax.post({
await Ajax.post({
url: '/auth/email_exists',
data: {
email
@ -103,7 +103,7 @@ export const checkPassword = (email, password) => async (dispatch, getState) =>
export const signup = (email, password) => async (dispatch, getState) => {
dispatch(setWorking(true))
dispatch(clearError())
if (/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
if (/^([a-zA-Z0-9_\-.]+)@([a-zA-Z0-9_\-.]+)\.([a-zA-Z]{2,5})$/.test(email)) {
try {
await Ajax.post({
url: '/auth/email_available',

View File

@ -2,7 +2,7 @@
import React from 'react'
import STYLE from '../../styles/shared/underlineinput.scss'
import '../../styles/shared/underlineinput.scss'
const UnderlineInput = props => (
<div className='underlined-input'>

View File

@ -1,7 +1,7 @@
'use strict'
import React from 'react'
import STYLE from '../../styles/shared/carousel.scss'
import '../../styles/shared/carousel.scss'
class Carousel extends React.Component {
constructor () {
@ -18,7 +18,7 @@ class Carousel extends React.Component {
render () {
return (
<section className='carousel-container'>
<div className='carousel' style={{width: this.getWidth(), left: this.getOffset()}}>
<div className='carousel' style={{ width: this.getWidth(), left: this.getOffset() }}>
{this.props.children}
</div>
</section>

View File

@ -3,12 +3,12 @@
import React from 'react'
import ReactDOM from 'react-dom'
import Progress from './components/Progress'
import Carousel, {CarouselItem} from './containers/Carousel'
import Carousel, { CarouselItem } from './containers/Carousel'
import UnderlineInput from './components/UnderlineInput'
import reducer from './reducers/login'
import {setEmail, setPassword, setCarousel, checkEmail, checkPassword, signup} from './actions/login'
import { setEmail, setPassword, setCarousel, checkEmail, checkPassword, signup } from './actions/login'
import STYLE from '../styles/login.scss'
import '../styles/login.scss'
class App extends React.Component {
constructor () {

View File

@ -3,7 +3,7 @@
import Actions from '../actions/login'
const reducer = (state = {}, action) => {
const {type, data} = action
const { type, data } = action
switch (type) {
case Actions.set_user:
return {

View File

@ -59,15 +59,15 @@ module.exports = {
// --------------------------------------------------------------------------
/****************************************************************************
*                         *
* *
* More adapter-specific options *
*                         *
* *
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
* > extra `ssl: true` option is mandatory and must be provided. *
*                         *
* More info:                   *
* https://sailsjs.com/config/datastores           *
*                         *
* *
* More info: *
* https://sailsjs.com/config/datastores *
* *
****************************************************************************/
// ssl: true,

View File

@ -59,15 +59,15 @@ module.exports = {
// --------------------------------------------------------------------------
/****************************************************************************
*                         *
* *
* More adapter-specific options *
*                         *
* *
* > For example, for some hosted PostgreSQL providers (like Heroku), the *
* > extra `ssl: true` option is mandatory and must be provided. *
*                         *
* More info:                   *
* https://sailsjs.com/config/datastores           *
*                         *
* *
* More info: *
* https://sailsjs.com/config/datastores *
* *
****************************************************************************/
// ssl: true,

View File

@ -93,7 +93,7 @@ module.exports.protocols = {
}
}
const EMAIL_REGEX = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i
const EMAIL_REGEX = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i
function validateEmail (email) {
return EMAIL_REGEX.test(email)

View File

@ -32,6 +32,7 @@
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"css-loader": "^1.0.1",
"eslint": "^5.8.0",
@ -76,7 +77,12 @@
},
"standard": {
"globals": [
"sails"
]
"sails",
"User",
"Book",
"Passport",
"_"
],
"parser": "babel-eslint"
}
}

View File

@ -19,7 +19,7 @@ module.exports = function (grunt) {
hashLength: 8,
hashFunction: function (source, encoding) {
if (!source || !encoding) {
throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: ' + require('util').inspect(source, {depth: null}) + '\nencoding: ' + require('util').inspect(encoding, {depth: null}))
throw new Error('Consistency violation: Cannot compute unique hash for production .css/.js cache-busting suffix, because `source` and/or `encoding` are falsey-- but they should be truthy strings! Here they are, respectively:\nsource: ' + require('util').inspect(source, { depth: null }) + '\nencoding: ' + require('util').inspect(encoding, { depth: null }))
}
return require('crypto').createHash('sha1').update(source, encoding).digest('hex')
}