Merge branch 'develop' into sabrecat/habitica-day

This commit is contained in:
Sabe Jones 2015-07-29 14:00:58 -05:00
commit 788fba08c2
2 changed files with 24 additions and 8 deletions

View file

@ -16,7 +16,7 @@
function questsFactory($rootScope,Content,Groups,User,Analytics) {
var user = User.user;
var party = $rootScope.party;
var party = Groups.party();
function lockQuest(quest,ignoreLevel) {
if (!ignoreLevel){
@ -31,7 +31,7 @@
if (item.unlockCondition && item.unlockCondition.condition === 'party invite') {
if (!confirm(window.env.t('mustInviteFriend'))) return;
return Groups.inviteOrStartParty(Groups.party());
return Groups.inviteOrStartParty(party);
}
if (item.previous && (!User.user.achievements.quests || (User.user.achievements.quests && !User.user.achievements.quests[item.previous]))){
return alert(window.env.t('unlockByQuesting', {title: Content.quests[item.previous].text()}));
@ -87,7 +87,7 @@
function questInit(){
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'quest','owner':true,'response':'accept','questName':$rootScope.selectedQuest.key});
Analytics.updateUser({'partyID':party.id,'partySize':party.memberCount});
Analytics.updateUser({'partyID':party._id,'partySize':party.memberCount});
party.$questAccept({key:$rootScope.selectedQuest.key}, function(){
party.$get();
$rootScope.$state.go('options.social.party');

View file

@ -87,16 +87,32 @@ module.exports.errorHandler = function(err, req, res, next) {
res.json(500,{err:message}); //res.end(err.message);
}
function isHTTP(req) {
var baseUrl = nconf.get("BASE_URL");
return (
req.headers['x-forwarded-proto'] &&
req.headers['x-forwarded-proto'] !== 'https' &&
nconf.get('NODE_ENV') === 'production' &&
baseUrl.indexOf('https') === 0
);
}
function isProxied(req) {
return (
req.headers['x-habitica-lb'] &&
req.headers['x-habitica-lb'] === 'Yes'
);
}
module.exports.forceSSL = function(req, res, next){
var baseUrl = nconf.get("BASE_URL");
// Note x-forwarded-proto is used by Heroku & nginx, you'll have to do something different if you're not using those
if (req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'] !== 'https'
&& nconf.get('NODE_ENV') === 'production'
&& baseUrl.indexOf('https') === 0) {
if(isHTTP(req) && !isProxied(req)) {
return res.redirect(baseUrl + req.url);
}
next()
next();
}
module.exports.cors = function(req, res, next) {