Implemented personal settings
This commit is contained in:
@@ -12,11 +12,11 @@ const saltRounds = 10;
|
||||
export const registerUser = async ({ email, username, password, language }) => {
|
||||
const iv = generateIv();
|
||||
const encryptedEmail = encrypt(email, iv);
|
||||
|
||||
console.log(email, iv, process.env.SECRET_KEY);
|
||||
const results = await sequelize.query(
|
||||
`SELECT * FROM "community"."user" WHERE public.pgp_sym_decrypt("email"::bytea, :key::text) = :email`,
|
||||
`SELECT * FROM "community"."user" WHERE "email" = :email`,
|
||||
{
|
||||
replacements: { key: process.env.SECRET_KEY, email },
|
||||
replacements: { key: process.env.SECRET_KEY, email: encryptedEmail },
|
||||
type: sequelize.QueryTypes.SELECT
|
||||
}
|
||||
);
|
||||
@@ -62,7 +62,6 @@ export const loginUser = async ({ username, password }) => {
|
||||
throw new Error('credentialsinvalid');
|
||||
}
|
||||
const match = await bcrypt.compare(password, user.password);
|
||||
console.log(match, password, user.password, await bcrypt.hash(password, saltRounds));
|
||||
if (!match) {
|
||||
throw new Error('credentialsinvalid');
|
||||
}
|
||||
@@ -72,12 +71,25 @@ export const loginUser = async ({ username, password }) => {
|
||||
},
|
||||
include: {
|
||||
model: UserParamType,
|
||||
as: 'paramType',
|
||||
where: {
|
||||
description: ['birthdate', 'gender']
|
||||
}
|
||||
}
|
||||
});
|
||||
return { id: user.hashedId, username: user.username, active: user.active, forwardDataInput: neededParams.length < 2 };
|
||||
const language = await UserParam.findOne({
|
||||
where: {
|
||||
userId: user.id
|
||||
},
|
||||
include: {
|
||||
model: UserParamType,
|
||||
as: 'paramType',
|
||||
where: {
|
||||
description: 'language'
|
||||
}
|
||||
}
|
||||
});
|
||||
return { id: user.hashedId, username: user.username, active: user.active, forwardDataInput: neededParams.length < 2, language: language.value };
|
||||
};
|
||||
|
||||
export const handleForgotPassword = async ({ email }) => {
|
||||
|
||||
Reference in New Issue
Block a user