Fix 10 linting errors

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

View File

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