fix: api token visible

This commit is contained in:
prafull-opensignlabs
2024-08-27 13:22:48 +05:30
parent bd4d333d59
commit 7b7b10c9a5
2 changed files with 24 additions and 8 deletions
@@ -1,7 +1,17 @@
import axios from 'axios';
import { cloudServerUrl } from '../../Utils.js';
export default async function getapitoken(request) {
try {
if (request?.user) {
const userId = request?.user?.id;
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
const userRes = await axios.get(serverUrl + '/users/me', {
headers: {
'X-Parse-Application-Id': process.env.APP_ID,
'X-Parse-Session-Token': request.headers['sessiontoken'],
},
});
const userId = userRes.data && userRes.data.objectId;
if (userId) {
const tokenQuery = new Parse.Query('appToken');
tokenQuery.equalTo('userId', { __type: 'Pointer', className: '_User', objectId: userId });
const res = await tokenQuery.first({ useMasterKey: true });