mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 10:33:50 +08:00
15 lines
457 B
TypeScript
15 lines
457 B
TypeScript
export default eventHandler((event) => {
|
|
const token = getHeader(event, 'Authorization');
|
|
if (!token) {
|
|
setResponseStatus(event, 401);
|
|
return useResponseError('UnauthorizedException', 'Unauthorized Exception');
|
|
}
|
|
|
|
const username = Buffer.from(token, 'base64').toString('utf8');
|
|
|
|
const user = MOCK_USERS.find((item) => item.username === username);
|
|
|
|
const { password: _pwd, ...userInfo } = user;
|
|
return useResponseSuccess(userInfo);
|
|
});
|