Merge branch 'main' into 20-create-dockerfile

This commit is contained in:
Ethan Girouard 2023-10-31 17:27:59 -04:00
commit fdd0a294ff
Signed by: eta357
GPG Key ID: 7BCDC36DFD11C146
3 changed files with 27 additions and 6 deletions

View File

@ -1,10 +1,20 @@
stages:
- lint
- build
# Lint the project
lint:
stage: lint
stage: build
image: node:18
script:
- npm ci
- npm run lint
# Do a test build of the project
build:
stage: build
image: node:18
variables:
SKIP_ENV_VALIDATION: 1
script:
- npm ci
- npm run build

View File

@ -18,6 +18,9 @@ const config = {
defaultLocale: "en",
},
output: "standalone",
eslint: {
ignoreDuringBuilds: true,
}
};
export default config;

View File

@ -7,6 +7,7 @@ import {
publicProcedure,
} from "~/server/api/trpc";
import UserModel from "~/models/users";
// Main login router for backend
export const loginRouter = createTRPCRouter({
@ -22,7 +23,7 @@ export const loginRouter = createTRPCRouter({
password_hash = hash;
});
// Store in database
const userModelData = ctx.UserModel().create({
const userModelData = UserModel.create({
username: input.username,
password: password_hash,
email: input.email,
@ -39,16 +40,23 @@ export const loginRouter = createTRPCRouter({
// Encryption using bcrypt salt and pepper hashing
const saltRounds = 10;
// Get hash from database
const password_hash = ctx.UserModel.find({username: input.username},'password');
let existing_user = await UserModel.findOne({'username': input.username},'password');
if (!existing_user) {
return {
user: null,
success: false,
};
}
let is_valid = false;
bcrypt.compare(input.password, password_hash, (err, result) => {
bcrypt.compare(input.password, existing_user.password, (err, result) => {
// returns result
is_valid = result;
});
// Return for sign in
if(is_valid) {
return {
user: ctx.UserModel.find({username: input.username}),
user: existing_user,
success: true,
};
}