feat: add switch orgs in org
This commit is contained in:
@@ -10,14 +10,15 @@ app
|
||||
middleware: ['auth'],
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const state = ctx.state?.tokenUser || {};
|
||||
const { id } = state;
|
||||
const tokenUser = ctx.state?.tokenUser || {};
|
||||
const { id } = tokenUser;
|
||||
const user = await User.findByPk(id, {
|
||||
logging: false,
|
||||
});
|
||||
if (!user) {
|
||||
throw new CustomError(500, 'user not found');
|
||||
}
|
||||
user.setTokenUser(tokenUser);
|
||||
ctx.body = await user.getInfo();
|
||||
})
|
||||
.addTo(app);
|
||||
@@ -68,12 +69,13 @@ app
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const { username, password, description, avatar, email } = ctx.query.data || {};
|
||||
const state = ctx.state?.tokenUser || {};
|
||||
const { id } = state;
|
||||
const tokenUser = ctx.state?.tokenUser || {};
|
||||
const { id } = tokenUser;
|
||||
const user = await User.findByPk(id);
|
||||
if (!user) {
|
||||
throw new CustomError(500, 'user not found');
|
||||
}
|
||||
user.setTokenUser(tokenUser);
|
||||
if (username) {
|
||||
user.username = username;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user