0
Fork 0
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:
Gao Sun 2022-07-21 21:35:39 +08:00 committed by GitHub
parent 7f06dfa575
commit 4bf6483ff4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);