An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Added types to database/users
dominicbachmann51a5b3b602e4
diff --git a/src/lib/database/users.ts b/src/lib/database/users.tsindex 7e5cc481eb..af7d11d3a8 100644--- a/src/lib/database/users.ts+++ b/src/lib/database/users.ts@@ -6,11 +6,26 @@ import { asyncExecShell, uniqueName } from '$lib/common';import * as db from '$lib/database';import { startCoolifyProxy } from '$lib/haproxy';-export async function hashPassword(password: string) {+import type { User } from '@prisma/client';++export async function hashPassword(password: string): Promise<string> {const saltRounds = 15;return bcrypt.hash(password, saltRounds);}-export async function login({ email, password, isLogin }) {++export async function login({+ email,+ password,+ isLogin+}: {+ email: string;+ password: string;+ isLogin: boolean;+}): Promise<{+ status: number;+ headers: { 'Set-Cookie': string };+ body: { userId: string; teamId: string; permission: string; isAdmin: boolean };+}> {const users = await prisma.user.count();const userFound = await prisma.user.findUnique({where: { email },@@ -52,7 +67,7 @@ export async function login({ email, password, isLogin }) {if (userFound) {if (userFound.type === 'email') {- const passwordMatch = await bcrypt.compare(password, userFound.password);+ const passwordMatch = bcrypt.compare(password, userFound.password);if (!passwordMatch) {throw {error: 'Wrong password or email address.'@@ -124,6 +139,6 @@ export async function login({ email, password, isLogin }) {};}-export async function getUser({ userId }) {+export async function getUser({ userId }: { userId: string }): Promise<User> {return await prisma.user.findUnique({ where: { id: userId } });}