mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
allow mobile to send analytics calls
This commit is contained in:
@@ -21,9 +21,10 @@ api.trackEvent = {
|
|||||||
// we authenticate these requests to make sure they actually came from a real user
|
// we authenticate these requests to make sure they actually came from a real user
|
||||||
middlewares: [authWithHeaders()],
|
middlewares: [authWithHeaders()],
|
||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
// As of now only web can track events using this route
|
if (req.headers['x-client'] !== 'habitica-web'
|
||||||
if (req.headers['x-client'] !== 'habitica-web') {
|
&& req.headers['x-client'] !== 'habitica-ios'
|
||||||
throw new NotAuthorized('Only habitica.com is allowed to track analytics events.');
|
&& req.headers['x-client'] !== 'habitica-android') {
|
||||||
|
throw new NotAuthorized('Only official clients are allowed to track analytics events.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { user } = res.locals;
|
const { user } = res.locals;
|
||||||
@@ -49,9 +50,10 @@ api.updateUserProperties = {
|
|||||||
// we authenticate these requests to make sure they actually came from a real user
|
// we authenticate these requests to make sure they actually came from a real user
|
||||||
middlewares: [authWithHeaders()],
|
middlewares: [authWithHeaders()],
|
||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
// As of now only web can track events using this route
|
if (req.headers['x-client'] !== 'habitica-web'
|
||||||
if (req.headers['x-client'] !== 'habitica-web') {
|
&& req.headers['x-client'] !== 'habitica-ios'
|
||||||
throw new NotAuthorized('Only habitica.com is allowed to track analytics events.');
|
&& req.headers['x-client'] !== 'habitica-android') {
|
||||||
|
throw new NotAuthorized('Only official clients are allowed to track analytics events.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { user } = res.locals;
|
const { user } = res.locals;
|
||||||
|
|||||||
Reference in New Issue
Block a user