module.exports = Self => {
    Self.remoteMethod('logout', {
        description: 'Logout a user with access token',
        accepts: [
            {
                arg: 'ctx',
                type: 'Object',
                http: {source: 'context'}
            }
        ],
        returns: {
            type: 'Boolean',
            root: true
        },
        http: {
            path: `/logout`,
            verb: 'POST'
        }
    });

    Self.logout = async function(ctx) {
        await Self.app.models.User.logout(ctx.req.accessToken.id);
        return true;
    };
};