Final?
This commit is contained in:
parent
c9c88c5a22
commit
f6b25a1a20
@ -20,12 +20,6 @@ const userController = new Elysia()
|
|||||||
if(msg.administrator == 1) {return new Response(await user.createToken(msg.id), {status: 418})}
|
if(msg.administrator == 1) {return new Response(await user.createToken(msg.id), {status: 418})}
|
||||||
return await user.createToken(msg.id)
|
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) => {
|
.put('/password', ({user}, body) => {
|
||||||
const oldPassword = body.oldPassword;
|
const oldPassword = body.oldPassword;
|
||||||
const newPassword = body.newPassword;
|
const newPassword = body.newPassword;
|
||||||
@ -38,7 +32,8 @@ const userController = new Elysia()
|
|||||||
{return new Response("Bad old password", {status: 400})}
|
{return new Response("Bad old password", {status: 400})}
|
||||||
}
|
}
|
||||||
const newPasswordHash = Bun.password.hash(body.newPassword)
|
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
|
export default userController
|
||||||
|
@ -9,6 +9,11 @@ const adminController = new Elysia()
|
|||||||
.all();
|
.all();
|
||||||
return users
|
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}) => {
|
.post('/user/group/:groupId', ({params: {groupId}, body}) => {
|
||||||
db.query(`INSERT INTO userGroups (UserID, GroupID) VALUES (?, ?);`).run(groupId, body.userId);
|
db.query(`INSERT INTO userGroups (UserID, GroupID) VALUES (?, ?);`).run(groupId, body.userId);
|
||||||
return "Added user to group"
|
return "Added user to group"
|
||||||
|
@ -30,8 +30,6 @@ const app = new Elysia()
|
|||||||
admin: msg.administrator
|
admin: msg.administrator
|
||||||
}
|
}
|
||||||
return { user }
|
return { user }
|
||||||
|
|
||||||
// return user here instead of bearer
|
|
||||||
})
|
})
|
||||||
.get('/', ({ user }) => user)
|
.get('/', ({ user }) => user)
|
||||||
.group('/user', (app) => app.use(userController))
|
.group('/user', (app) => app.use(userController))
|
||||||
|
Loading…
Reference in New Issue
Block a user