fix: use lowercase email for user model findOne method
This commit is contained in:
@@ -13,12 +13,18 @@ type Params = {
|
||||
};
|
||||
};
|
||||
|
||||
const createUser = async (_parent: unknown, params: Params, context: Context) => {
|
||||
const createUser = async (
|
||||
_parent: unknown,
|
||||
params: Params,
|
||||
context: Context
|
||||
) => {
|
||||
context.currentUser.can('create', 'User');
|
||||
|
||||
const { fullName, email, password } = params.input;
|
||||
|
||||
const existingUser = await User.query().findOne({ email });
|
||||
const existingUser = await User.query().findOne({
|
||||
email: email.toLowerCase(),
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
throw new Error('User already exists!');
|
||||
|
@@ -15,7 +15,7 @@ type Params = {
|
||||
const forgotPassword = async (_parent: unknown, params: Params) => {
|
||||
const { email } = params.input;
|
||||
|
||||
const user = await User.query().findOne({ email });
|
||||
const user = await User.query().findOne({ email: email.toLowerCase() });
|
||||
|
||||
if (!user) {
|
||||
throw new Error('Email address not found!');
|
||||
|
@@ -12,7 +12,9 @@ type Params = {
|
||||
const registerUser = async (_parent: unknown, params: Params) => {
|
||||
const { fullName, email, password } = params.input;
|
||||
|
||||
const existingUser = await User.query().findOne({ email });
|
||||
const existingUser = await User.query().findOne({
|
||||
email: email.toLowerCase(),
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
throw new Error('User already exists!');
|
||||
|
Reference in New Issue
Block a user