28 lines
676 B
JavaScript
28 lines
676 B
JavaScript
|
|
module.exports = Self => {
|
|
Self.remoteMethodCtx('shareToken', {
|
|
description: 'Returns token to view files or images and share it',
|
|
accessType: 'WRITE',
|
|
accepts: [],
|
|
returns: {
|
|
type: 'Object',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/shareToken`,
|
|
verb: 'GET'
|
|
}
|
|
});
|
|
|
|
Self.shareToken = async function(ctx) {
|
|
const {accessToken: token} = ctx.req;
|
|
|
|
const user = await Self.findById(token.userId);
|
|
const multimediaToken = await user.accessTokens.create({
|
|
scopes: ['read:multimedia']
|
|
});
|
|
|
|
return {multimediaToken};
|
|
};
|
|
};
|