Fix 10 linting errors
This commit is contained in:
@ -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,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user