mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-27 06:23:41 -04:00
Merge branch 'master' into production
This commit is contained in:
commit
721ae833e9
4 changed files with 7 additions and 3 deletions
|
@ -337,6 +337,7 @@
|
|||
tip_recurse: "To iterate is human, to recurse divine. - L. Peter Deutsch"
|
||||
tip_free_your_mind: "You have to let it all go, Neo. Fear, doubt, and disbelief. Free your mind. - Morpheus"
|
||||
tip_strong_opponents: "Even the strongest of opponents always has a weakness. - Itachi Uchiha"
|
||||
tip_paper_and_pen: "Before you start coding, you can always plan with a sheet of paper and a pen."
|
||||
|
||||
game_menu:
|
||||
inventory_tab: "Inventory"
|
||||
|
|
|
@ -77,3 +77,4 @@
|
|||
strong.tip.rare(data-i18n='play_level.tip_recurse') To iterate is human, to recurse divine. - L. Peter Deutsch
|
||||
strong.tip.rare(data-i18n='play_level.tip_free_your_mind') You have to let it all go, Neo. Fear, doubt, and disbelief. Free your mind. - Morpheus
|
||||
strong.tip.rare(data-i18n='play_level.tip_strong_opponents') Even the strongest of opponents always has a weakness. - Itachi Uchiha
|
||||
strong.tip.rare(data-i18n='play_level.tip_paper_and_pen') Before you start coding, you can always plan with a sheet of paper and a pen.
|
||||
|
|
|
@ -202,7 +202,7 @@ module.exports.makeNewUser = makeNewUser = (req) ->
|
|||
user.set 'testGroupNumber', Math.floor(Math.random() * 256) # also in app/core/auth
|
||||
lang = languages.languageCodeFromAcceptedLanguages req.acceptedLanguages
|
||||
user.set 'preferredLanguage', lang if lang[...2] isnt 'en'
|
||||
user.set 'lastIP', req.connection.remoteAddress
|
||||
user.set 'lastIP', (req.headers['x-forwarded-for'] or req.connection.remoteAddress)?.split(' ')[0]
|
||||
user.set 'chinaVersion', true if req.chinaVersion
|
||||
log.info "making new user #{user.get('_id')} with language #{user.get('preferredLanguage')} of #{req.acceptedLanguages} and chinaVersion #{req.chinaVersion} on #{if config.tokyo then 'Tokyo' else 'US'} server and lastIP #{req.connection.remoteAddress}."
|
||||
user
|
||||
|
|
|
@ -80,12 +80,14 @@ setupPassportMiddleware = (app) ->
|
|||
|
||||
setupChinaRedirectMiddleware = (app) ->
|
||||
shouldRedirectToChinaVersion = (req) ->
|
||||
speaksChinese = req.acceptedLanguages[0]?.indexOf('zh') isnt -1
|
||||
firstLanguage = req.acceptedLanguages[0]
|
||||
speaksChinese = firstLanguage and firstLanguage.indexOf('zh') isnt -1
|
||||
unless config.tokyo
|
||||
ip = req.headers['x-forwarded-for'] or req.connection.remoteAddress
|
||||
ip = ip?.split(' ')[0] # If there are two IP addresses, say because of CloudFlare, we just take the first.
|
||||
geo = geoip.lookup(ip)
|
||||
if speaksChinese or geo?.country is "CN"
|
||||
log.info("Should we redirect to Tokyo server? speaksChinese: #{speaksChinese}, acceptedLanguages: #{req.acceptedLanguages[0]}, ip: #{ip}, geo: #{geo} -- so redirecting? #{geo?.country is 'CN' and speaksChinese}")
|
||||
log.info("Should we redirect to Tokyo server? speaksChinese: #{speaksChinese}, firstLanguage: #{firstLanguage}, ip: #{ip}, geo: #{geo} -- so redirecting? #{geo?.country is 'CN' and speaksChinese}")
|
||||
return geo?.country is "CN" and speaksChinese
|
||||
else
|
||||
log.info("We are on Tokyo server. speaksChinese: #{speaksChinese}, acceptedLanguages: #{req.acceptedLanguages[0]}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue