From 7240a6ad4b028f9c944d14fb219cd41f8ad1b0f0 Mon Sep 17 00:00:00 2001 From: Hans Trautlein Date: Tue, 1 Nov 2016 18:06:27 -0700 Subject: [PATCH 1/2] Make email address case insensitive --- client/src/components/Login/index.jsx | 6 +++--- client/src/components/Signup/index.jsx | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/components/Login/index.jsx b/client/src/components/Login/index.jsx index ee71830..9c6eb5c 100644 --- a/client/src/components/Login/index.jsx +++ b/client/src/components/Login/index.jsx @@ -7,8 +7,8 @@ class Login extends Component { super(props); this.state = { inputs: { - emailAddress: null, - password: null, + emailAddress: '', + password: '', }, error: '', }; @@ -32,7 +32,7 @@ class Login extends Component { submitLoginForm(event) { event.preventDefault(); - Request.postLogin(this.state.inputs, (res) => { + Request.postLogin({emailAddress: this.state.inputs.emailAddress.toLowerCase(), password: this.state.inputs.password}, (res) => { if (res.status === 201) { // eslint-disable-next-line no-undef localStorage.setItem('piddleToken', res.body.data.token); diff --git a/client/src/components/Signup/index.jsx b/client/src/components/Signup/index.jsx index 9629594..6a6b99c 100644 --- a/client/src/components/Signup/index.jsx +++ b/client/src/components/Signup/index.jsx @@ -37,7 +37,9 @@ class Signup extends Component { submitSignupForm(event) { event.preventDefault(); - Request.postSignup(this.state.inputs, (res) => { + let toSend = this.state.inputs; + toSend.emailAddress = toSend.emailAddress.toLowerCase(); + Request.postSignup(toSend, (res) => { if (res.status === 201) { // eslint-disable-next-line no-undef localStorage.setItem('piddleToken', res.body.data.token); From 81b9a617be46259e1f905dd94a322b36462648d7 Mon Sep 17 00:00:00 2001 From: Hans Trautlein Date: Tue, 1 Nov 2016 18:11:06 -0700 Subject: [PATCH 2/2] Non-lowercase emails won't add to database now --- server/db.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/db.js b/server/db.js index 7c801c9..c493cfe 100644 --- a/server/db.js +++ b/server/db.js @@ -59,6 +59,7 @@ const User = sequelize.define('user', { allowNull: false, isEmail: true, unique: true, + isLowercase: true }, password: { type: Sequelize.STRING,