mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2025-01-19 03:49:16 -07:00
36 lines
653 B
JavaScript
36 lines
653 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Module dependencies
|
|
*/
|
|
import AuthSess from '../../../models/auth-session';
|
|
import serialize from '../../../serializers/auth-session';
|
|
|
|
/**
|
|
* Show a session
|
|
*
|
|
* @param {Object} params
|
|
* @param {Object} user
|
|
* @return {Promise<object>}
|
|
*/
|
|
module.exports = (params, user) =>
|
|
new Promise(async (res, rej) =>
|
|
{
|
|
// Get 'token' parameter
|
|
const token = params.token;
|
|
if (token == null) {
|
|
return rej('token is required');
|
|
}
|
|
|
|
// Lookup session
|
|
const session = await AuthSess.findOne({
|
|
token: token
|
|
});
|
|
|
|
if (session == null) {
|
|
return rej('session not found');
|
|
}
|
|
|
|
// Response
|
|
res(await serialize(session, user));
|
|
});
|