Merge branch 'hotfix/21.56.9' into master
[gitter.git] / server / api / private / fingerprint.js
blob49ee8ee8040a65a6f7885123871720f8b4ad0b8c
1 'use strict';
3 const StatusError = require('statuserror');
4 var fingerprintingService = require('gitter-web-fingerprinting/lib/fingerprinting-service');
6 /**
7  * Submit a browser fingerprint for a user's browser
8  */
9 module.exports = function(req, res, next) {
10   if (!req.user) return next(new StatusError(401, 'Anonymous users cannot be fingerprinted'));
11   var userId = req.user._id;
12   var fingerprint = req.body && req.body.fp;
14   return fingerprintingService
15     .recordFingerprint(userId, fingerprint, req.ip)
16     .then(function() {
17       res.send('OK');
18     })
19     .catch(next);