Merge branch 'main' into 20-create-dockerfile
This commit is contained in:
commit
fdd0a294ff
@ -1,10 +1,20 @@
|
|||||||
stages:
|
stages:
|
||||||
- lint
|
- build
|
||||||
|
|
||||||
# Lint the project
|
# Lint the project
|
||||||
lint:
|
lint:
|
||||||
stage: lint
|
stage: build
|
||||||
image: node:18
|
image: node:18
|
||||||
script:
|
script:
|
||||||
- npm ci
|
- npm ci
|
||||||
- npm run lint
|
- 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
|
||||||
|
@ -18,6 +18,9 @@ const config = {
|
|||||||
defaultLocale: "en",
|
defaultLocale: "en",
|
||||||
},
|
},
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
|
eslint: {
|
||||||
|
ignoreDuringBuilds: true,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
publicProcedure,
|
publicProcedure,
|
||||||
} from "~/server/api/trpc";
|
} from "~/server/api/trpc";
|
||||||
|
|
||||||
|
import UserModel from "~/models/users";
|
||||||
|
|
||||||
// Main login router for backend
|
// Main login router for backend
|
||||||
export const loginRouter = createTRPCRouter({
|
export const loginRouter = createTRPCRouter({
|
||||||
@ -22,7 +23,7 @@ export const loginRouter = createTRPCRouter({
|
|||||||
password_hash = hash;
|
password_hash = hash;
|
||||||
});
|
});
|
||||||
// Store in database
|
// Store in database
|
||||||
const userModelData = ctx.UserModel().create({
|
const userModelData = UserModel.create({
|
||||||
username: input.username,
|
username: input.username,
|
||||||
password: password_hash,
|
password: password_hash,
|
||||||
email: input.email,
|
email: input.email,
|
||||||
@ -39,16 +40,23 @@ 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
|
||||||
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;
|
let is_valid = false;
|
||||||
bcrypt.compare(input.password, password_hash, (err, result) => {
|
bcrypt.compare(input.password, existing_user.password, (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: existing_user,
|
||||||
success: true,
|
success: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user