Fix 10 linting errors

This commit is contained in:
2023-10-13 16:55:21 -04:00
parent 6c028d8e22
commit 0b0d3e3a31

View File

@ -16,16 +16,16 @@ export const loginRouter = createTRPCRouter({
.mutation(async ({ ctx, input }) => { .mutation(async ({ ctx, input }) => {
// Encryption using bcrypt salt and pepper hashing // Encryption using bcrypt salt and pepper hashing
const saltRounds = 10; const saltRounds = 10;
let password_hash: string = ""; let password_hash = "";
bcrypt.hash(input.password, saltRounds, (err,hash) => { bcrypt.hash(input.password, saltRounds, (err,hash) => {
password_hash = hash; password_hash = hash;
}); });
// Store in database // Store in database
const userModelData = ctx.UserModel().create({ const userModelData = ctx.UserModel().create({
username:input.username, username: input.username,
password:password_hash, password: password_hash,
email:input.email, email: input.email,
}); });
// Return greeting information // Return greeting information
return { return {
@ -39,16 +39,16 @@ export const loginRouter = createTRPCRouter({
// Encryption using bcrypt salt and pepper hashing // Encryption using bcrypt salt and pepper hashing
const saltRounds = 10; const saltRounds = 10;
// Get hash from database // Get hash from database
let password_hash = ctx.UserModel.find({'username': input.username},'password'); const password_hash = ctx.UserModel.find({username: input.username},'password');
let is_valid: boolean = false; let is_valid = false;
bcrypt.compare(input.password, password_hash, function(err, result) { bcrypt.compare(input.password, password_hash, (err, result) => {
// returns result // returns result
is_valid = result; is_valid = result;
}); });
// Return for sign in // Return for sign in
if(is_valid) { if(is_valid) {
return { return {
user: ctx.UserModel.find({'username': input.username}), user: ctx.UserModel.find({username: input.username}),
success: true, success: true,
}; };
} }