summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/i.ts
blob: 150ab34a0fa6a5842c3da78316686ce1914c50b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import User, { pack, ILocalUser } from '../../../models/user';
import { IApp } from '../../../models/app';

/**
 * Show myself
 */
export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
	const isSecure = user != null && app == null;

	// Serialize
	res(await pack(user, user, {
		detail: true,
		includeSecrets: isSecure
	}));

	// Update lastUsedAt
	User.update({ _id: user._id }, {
		$set: {
			lastUsedAt: new Date()
		}
	});
});