better handling whenno cloudflare country header is given
This commit is contained in:
parent
e3be885cd0
commit
c16c427ebd
|
@ -21,7 +21,7 @@ function authenticateClient(req) {
|
|||
return new Promise(
|
||||
((resolve) => {
|
||||
router(req, {}, async () => {
|
||||
const country = req.headers['cf-ipcountry'];
|
||||
const country = req.headers['cf-ipcountry'] || 'xx';
|
||||
const user = (req.user) ? req.user
|
||||
: new User(null, getIPFromRequest(req));
|
||||
user.country = country.toLowerCase();
|
||||
|
|
|
@ -12,6 +12,9 @@ import ccCoords from '../data/countrycode-coords-array.json';
|
|||
* @return coords X/Y coordinates of the country on the canvas
|
||||
*/
|
||||
export function ccToCoords(cc: string) {
|
||||
if (!cc) {
|
||||
return [0, 0];
|
||||
}
|
||||
const country = cc.toLowerCase();
|
||||
const coords = ccCoords[country];
|
||||
return (coords) || [0, 0];
|
||||
|
|
Loading…
Reference in New Issue
Block a user