diff --git a/backend/src/User/Controller.ts b/backend/src/User/Controller.ts index 193fdf1..6acb4a1 100644 --- a/backend/src/User/Controller.ts +++ b/backend/src/User/Controller.ts @@ -20,12 +20,6 @@ const userController = new Elysia() if(msg.administrator == 1) {return new Response(await user.createToken(msg.id), {status: 418})} return await user.createToken(msg.id) }) - // .post('/register', async({body}) => { - // return await Bun.password.hash(body.password); - // }) - .get('/otp', () => { - return authenticator.generateSecret(); - }) .put('/password', ({user}, body) => { const oldPassword = body.oldPassword; const newPassword = body.newPassword; @@ -38,7 +32,8 @@ const userController = new Elysia() {return new Response("Bad old password", {status: 400})} } const newPasswordHash = Bun.password.hash(body.newPassword) - const msg = db.query(`update users set password = ? WHERE id = ?;`).run(newPassword. user.id); + db.query(`update users set password = ? WHERE id = ?;`).run(newPassword. user.id); + "password updated" }) export default userController diff --git a/backend/src/admin/Controller.ts b/backend/src/admin/Controller.ts index af2d949..35f8ad4 100644 --- a/backend/src/admin/Controller.ts +++ b/backend/src/admin/Controller.ts @@ -9,6 +9,11 @@ const adminController = new Elysia() .all(); return users }) +.get('/user/groups/:userID', ({params: {userID}}) => { + const userGroup = db.query(`SELECT groups.GroupId, groups.GroupName FROM groups JOIN userGroups ON groups.GroupID = userGroups.GroupID JOIN users ON userGroups.UserID = users.id WHERE users.id = ?;`) + .all(userID); + return userGroup +}) .post('/user/group/:groupId', ({params: {groupId}, body}) => { db.query(`INSERT INTO userGroups (UserID, GroupID) VALUES (?, ?);`).run(groupId, body.userId); return "Added user to group" diff --git a/backend/src/index.ts b/backend/src/index.ts index f209e08..a61aa37 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -29,9 +29,7 @@ const app = new Elysia() name: msg.name, admin: msg.administrator } - return { user } - - // return user here instead of bearer + return { user } }) .get('/', ({ user }) => user) .group('/user', (app) => app.use(userController)) diff --git a/backend/src/utils/groups.ts b/backend/src/utils/groups.ts deleted file mode 100644 index e69de29..0000000