mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
feat(core): api GET /me (#1650)
This commit is contained in:
parent
7f06dfa575
commit
4bf6483ff4
1 changed files with 10 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import { arbitraryObjectGuard } from '@logto/schemas';
|
||||
import { arbitraryObjectGuard, userInfoSelectFields } from '@logto/schemas';
|
||||
import { passwordRegEx } from '@logto/shared';
|
||||
import pick from 'lodash.pick';
|
||||
import { object, string } from 'zod';
|
||||
|
||||
import { encryptUserPassword } from '@/lib/user';
|
||||
|
@ -9,6 +10,14 @@ import { findUserById, updateUserById } from '@/queries/user';
|
|||
import { AuthedRouter } from './types';
|
||||
|
||||
export default function meRoutes<T extends AuthedRouter>(router: T) {
|
||||
router.get('/me', async (ctx, next) => {
|
||||
const user = await findUserById(ctx.auth);
|
||||
|
||||
ctx.body = pick(user, ...userInfoSelectFields);
|
||||
|
||||
return next();
|
||||
});
|
||||
|
||||
router.get('/me/custom-data', async (ctx, next) => {
|
||||
const { customData } = await findUserById(ctx.auth);
|
||||
|
||||
|
|
Loading…
Reference in a new issue