Skip to content

Commit 65869d2

Browse files
authored
Merge pull request #628 from sugarforever/fix/bcrypt-broken-docker
fix: clean up legacy code with bcrypt
2 parents 1d55326 + b8e6b54 commit 65869d2

File tree

4 files changed

+41
-50
lines changed

4 files changed

+41
-50
lines changed

docker-compose.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ services:
1515
- COHERE_API_KEY=xxxxx
1616
- COHERE_MODEL=ms-marco-MiniLM-L-6-v2
1717
- COHERE_BASE_URL=http://peanutshell:8000/v1
18-
image: 0001coder/chatollama:latest
19-
pull_policy: always
18+
image: chat-ollama:dev
19+
# Using locally built image instead of pulling from Docker Hub
20+
# image: 0001coder/chatollama:latest
21+
# pull_policy: always
2022
#extra_hosts:
2123
# - "host.docker.internal:host-gateway"
2224
ports:

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"devDependencies": {
1717
"@nuxtjs/google-fonts": "^3.2.0",
1818
"@sidebase/nuxt-auth": "^0.7.1",
19-
"@types/bcrypt": "^5.0.2",
2019
"@types/html-to-text": "^9.0.4",
2120
"@types/jsdom": "^21.1.6",
2221
"@types/jsonwebtoken": "^9.0.6",

pnpm-lock.yaml

-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/api/auth/signup.post.ts

+37-37
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
import prisma from "@/server/utils/prisma"
2-
import bcrypt from "bcrypt"
2+
import bcrypt from "bcryptjs"
33

44
export enum Role {
5-
USER = 0,
6-
ADMIN = 1,
7-
SUPERADMIN = 2
5+
USER = 0,
6+
ADMIN = 1,
7+
SUPERADMIN = 2
88
}
99

1010
const signUp = async (name: string, email: string, password: string) => {
11-
if (!name || !password) {
12-
throw createError({
13-
statusCode: 400,
14-
statusMessage: 'Name and password cannot be empty'
15-
})
16-
}
17-
18-
const exist = await prisma.user.count({ where: { name: name } }) > 0
19-
if (exist) {
20-
throw createError({
21-
statusCode: 409,
22-
statusMessage: `User ${name} already exist`
23-
})
24-
}
11+
if (!name || !password) {
12+
throw createError({
13+
statusCode: 400,
14+
statusMessage: 'Name and password cannot be empty'
15+
})
16+
}
2517

26-
const hashedPassword = await bcrypt.hash(password, 10)
27-
return await prisma.user.create({
28-
data: {
29-
name,
30-
email,
31-
password: hashedPassword,
32-
role: process.env.SUPER_ADMIN_NAME === name ? Role.SUPERADMIN : Role.USER
18+
const exist = await prisma.user.count({ where: { name: name } }) > 0
19+
if (exist) {
20+
throw createError({
21+
statusCode: 409,
22+
statusMessage: `User ${name} already exist`
23+
})
3324
}
34-
})
25+
26+
const hashedPassword = await bcrypt.hash(password, 10)
27+
return await prisma.user.create({
28+
data: {
29+
name,
30+
email,
31+
password: hashedPassword,
32+
role: process.env.SUPER_ADMIN_NAME === name ? Role.SUPERADMIN : Role.USER
33+
}
34+
})
3535
}
3636

3737
export default defineEventHandler(async (event) => {
38-
const { name, email, password } = await readBody(event)
39-
try {
40-
const result = await signUp(name, email, password)
41-
return {
42-
status: "success",
43-
user: {
44-
id: result?.id
45-
}
38+
const { name, email, password } = await readBody(event)
39+
try {
40+
const result = await signUp(name, email, password)
41+
return {
42+
status: "success",
43+
user: {
44+
id: result?.id
45+
}
46+
}
47+
} catch (error) {
48+
throw error
4649
}
47-
} catch (error) {
48-
throw error
49-
}
5050
})

0 commit comments

Comments
 (0)