Skip to content

Commit

Permalink
normalize email address on sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott1 committed Nov 25, 2019
1 parent 3b6adeb commit de89345
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions final/resolvers/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ module.exports = {
},

signIn: async (parent, { username, email, password }, { models }) => {
if (email) {
// normalize email address
email = email.trim().toLowerCase();
}

const user = await models.User.findOne({
$or: [{ email }, { username }]
});
Expand Down
5 changes: 5 additions & 0 deletions solutions/05-Authentication/resolvers/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ module.exports = {
}
},
signIn: async (parent, { username, email, password }, { models }) => {
if (email) {
// normalize email address
email = email.trim().toLowerCase();
}

const user = await models.User.findOne({
$or: [{ email }, { username }]
});
Expand Down
5 changes: 5 additions & 0 deletions solutions/06-User-Actions/resolvers/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ module.exports = {
},

signIn: async (parent, { username, email, password }, { models }) => {
if (email) {
// normalize email address
email = email.trim().toLowerCase();
}

const user = await models.User.findOne({
$or: [{ email }, { username }]
});
Expand Down
4 changes: 4 additions & 0 deletions solutions/07-Details/resolvers/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ module.exports = {
},

signIn: async (parent, { username, email, password }, { models }) => {
if (email) {
// normalize email address
email = email.trim().toLowerCase();
}
const user = await models.User.findOne({
$or: [{ email }, { username }]
});
Expand Down

0 comments on commit de89345

Please sign in to comment.