diff --git a/core/src/auth/local.ts b/core/src/auth/local.ts index 45cc04104..478a7803b 100644 --- a/core/src/auth/local.ts +++ b/core/src/auth/local.ts @@ -14,7 +14,10 @@ const local = fp((app: FastifyInstance, _: {}, done: () => void) => { const password = (req.body as User).password!; const hashedPass = await hash(password, PASSWORD_SALT_ROUNDS); try { - const user = await app.users.create({ username, password: hashedPass }); + const user = await app.users.create({ + username, + password: hashedPass, + }); const jwt = app.jwt.sign( { id: user._id.toString() }, { expiresIn: TOKEN_EXPIRES_IN } diff --git a/core/src/db/users.ts b/core/src/db/users.ts index 45185bea8..d3b7a19ec 100644 --- a/core/src/db/users.ts +++ b/core/src/db/users.ts @@ -4,7 +4,8 @@ import { Schema } from "mongoose"; const users = fp((app: FastifyInstance, _: {}, done: () => void) => { const schema = new Schema({ - username: { type: String, index: true }, + username: { type: String, index: true, required: true }, + permissions: { type: Number, default: 0 }, password: String, avatar: String, githubID: { type: Number, index: true }, diff --git a/core/src/main.ts b/core/src/main.ts index d0906a39d..5d75a6af3 100644 --- a/core/src/main.ts +++ b/core/src/main.ts @@ -17,4 +17,4 @@ app.listen(PORT, (err, address) => { process.exit(1); } console.log(`monitor core listening at ${address}`); -}); +}); \ No newline at end of file diff --git a/periphery/package.json b/periphery/package.json index baf670aea..e107fc137 100644 --- a/periphery/package.json +++ b/periphery/package.json @@ -9,7 +9,8 @@ }, "devDependencies": { "@types/dockerode": "^3.3.3", - "typescript": "^4.6.2" + "typescript": "^4.6.2", + "@monitor/types": "1.0.0" }, "dependencies": { "dockerode": "^3.3.1", diff --git a/types/types.d.ts b/types/types.d.ts index af11b68c2..1897a5f4c 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -1,7 +1,8 @@ export type User = { - _id: string; - username: string; - password?: string; - githubID?: string; - avatar?: string; -} \ No newline at end of file + _id: string; + username: string; + permissions: number; + password?: string; + githubID?: string; + avatar?: string; +}; \ No newline at end of file