feat: add me

This commit is contained in:
2024-10-14 16:23:29 +08:00
parent 1eb65859e6
commit 64f89b60dc
5 changed files with 82 additions and 118 deletions

View File

@@ -67,7 +67,7 @@ app
middleware: ['auth'],
})
.define(async (ctx) => {
const { username, password, description } = ctx.query;
const { username, password, description, avatar, email } = ctx.query.data || {};
const state = ctx.state?.tokenUser || {};
const { id } = state;
const user = await User.findByPk(id);
@@ -83,6 +83,12 @@ app
if (description) {
user.description = description;
}
if (avatar) {
user.avatar = avatar;
}
if (email) {
user.email = email;
}
await user.save();
ctx.body = await user.getInfo();
})