Merge branch 'release' into develop

This commit is contained in:
Sabe Jones
2019-01-24 13:14:19 -06:00
9 changed files with 82 additions and 24 deletions

View File

@@ -77,5 +77,6 @@
"STRIPE_PUB_KEY": "22223333444455556666777788889999", "STRIPE_PUB_KEY": "22223333444455556666777788889999",
"TEST_DB_URI": "mongodb://localhost/habitrpg_test", "TEST_DB_URI": "mongodb://localhost/habitrpg_test",
"TRANSIFEX_SLACK_CHANNEL": "transifex", "TRANSIFEX_SLACK_CHANNEL": "transifex",
"WEB_CONCURRENCY": 1 "WEB_CONCURRENCY": 1,
"SKIP_SSL_CHECK_KEY": "key"
} }

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "habitica", "name": "habitica",
"version": "4.80.5", "version": "4.80.8",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,7 +1,7 @@
{ {
"name": "habitica", "name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.", "description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "4.80.5", "version": "4.80.8",
"main": "./website/server/index.js", "main": "./website/server/index.js",
"dependencies": { "dependencies": {
"@slack/client": "^3.8.1", "@slack/client": "^3.8.1",

View File

@@ -73,6 +73,56 @@ describe('redirects middleware', () => {
expect(res.redirect).to.have.not.been.called; expect(res.redirect).to.have.not.been.called;
}); });
it('does not redirect if passed skip ssl request param is passed with corrrect key', () => {
let nconfStub = sandbox.stub(nconf, 'get');
nconfStub.withArgs('BASE_URL').returns('https://habitica.com');
nconfStub.withArgs('IS_PROD').returns(true);
nconfStub.withArgs('SKIP_SSL_CHECK_KEY').returns('test-key');
req.header = sandbox.stub().withArgs('x-forwarded-proto').returns('http');
req.originalUrl = '/static/front';
req.query.skipSSLCheck = 'test-key';
const attachRedirects = requireAgain(pathToRedirectsMiddleware);
attachRedirects.forceSSL(req, res, next);
expect(res.redirect).to.have.not.been.called;
});
it('does redirect if skip ssl request param is passed with incorrrect key', () => {
let nconfStub = sandbox.stub(nconf, 'get');
nconfStub.withArgs('BASE_URL').returns('https://habitica.com');
nconfStub.withArgs('IS_PROD').returns(true);
nconfStub.withArgs('SKIP_SSL_CHECK_KEY').returns('test-key');
req.header = sandbox.stub().withArgs('x-forwarded-proto').returns('http');
req.originalUrl = '/static/front?skipSSLCheck=INVALID';
req.query.skipSSLCheck = 'INVALID';
const attachRedirects = requireAgain(pathToRedirectsMiddleware);
attachRedirects.forceSSL(req, res, next);
expect(res.redirect).to.be.calledOnce;
expect(res.redirect).to.be.calledWith('https://habitica.com/static/front?skipSSLCheck=INVALID');
});
it('does redirect if skip ssl check key is not set', () => {
let nconfStub = sandbox.stub(nconf, 'get');
nconfStub.withArgs('BASE_URL').returns('https://habitica.com');
nconfStub.withArgs('IS_PROD').returns(true);
nconfStub.withArgs('SKIP_SSL_CHECK_KEY').returns(null);
req.header = sandbox.stub().withArgs('x-forwarded-proto').returns('http');
req.originalUrl = '/static/front';
req.query.skipSSLCheck = 'INVALID';
const attachRedirects = requireAgain(pathToRedirectsMiddleware);
attachRedirects.forceSSL(req, res, next);
expect(res.redirect).to.be.calledOnce;
expect(res.redirect).to.be.calledWith('https://habitica.com/static/front');
});
}); });
context('forceHabitica', () => { context('forceHabitica', () => {

View File

@@ -1,72 +1,78 @@
.promo_armoire_backgrounds_201901 { .promo_armoire_backgrounds_201901 {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px -148px; background-position: -445px 0px;
width: 423px; width: 423px;
height: 147px; height: 147px;
} }
.promo_bird_buddies_bundle { .promo_bird_buddies_bundle {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -424px 0px; background-position: -421px -337px;
width: 420px; width: 420px;
height: 147px; height: 147px;
} }
.promo_g1g1 { .promo_g1g1 {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -241px -444px; background-position: -241px -633px;
width: 237px; width: 237px;
height: 150px; height: 150px;
} }
.promo_npc_alex { .promo_npc_alex {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -403px -296px; background-position: -566px -485px;
width: 162px; width: 162px;
height: 138px; height: 138px;
} }
.promo_seasonal_shop { .promo_seasonal_shop {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -566px -296px; background-position: -403px -485px;
width: 162px; width: 162px;
height: 138px; height: 138px;
} }
.promo_snow_potions { .promo_snow_potions {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px 0px; background-position: -445px -148px;
width: 423px; width: 423px;
height: 147px; height: 147px;
} }
.promo_take_this { .promo_take_this {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -729px -296px; background-position: -729px -485px;
width: 96px; width: 96px;
height: 69px; height: 69px;
} }
.promo_winter_wonderland_2019 { .promo_winter_wonderland_2019 {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px -296px; background-position: 0px -485px;
width: 402px; width: 402px;
height: 147px; height: 147px;
} }
.promo_wintery_skins { .promo_wintery_skins {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -424px -148px; background-position: 0px -337px;
width: 420px; width: 420px;
height: 147px; height: 147px;
} }
.customize-option.promo_wintery_skins { .customize-option.promo_wintery_skins {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -449px -163px; background-position: -25px -352px;
width: 60px; width: 60px;
height: 60px; height: 60px;
} }
.scene_hat_guild {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px 0px;
width: 444px;
height: 336px;
}
.scene_starting_over { .scene_starting_over {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: -479px -444px; background-position: -479px -633px;
width: 150px; width: 150px;
height: 150px; height: 150px;
} }
.scene_todo_list { .scene_todo_list {
background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png'); background-image: url('~assets/images/sprites/spritesmith-largeSprites-0.png');
background-position: 0px -444px; background-position: 0px -633px;
width: 240px; width: 240px;
height: 195px; height: 195px;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -3,7 +3,7 @@ import { authWithHeaders } from '../../middlewares/auth';
let api = {}; let api = {};
// @TODO export this const, cannot export it from here because only routes are exported from controllers // @TODO export this const, cannot export it from here because only routes are exported from controllers
const LAST_ANNOUNCEMENT_TITLE = 'LAST CHANCE: GIFT A SUBSCRIPTION AND GET ONE FREE!'; const LAST_ANNOUNCEMENT_TITLE = 'GUILD SPOTLIGHT: NEW AND NOTABLE!';
const worldDmg = { // @TODO const worldDmg = { // @TODO
bailey: false, bailey: false,
}; };
@@ -30,16 +30,13 @@ api.getNews = {
<div class="mr-3 ${baileyClass}"></div> <div class="mr-3 ${baileyClass}"></div>
<div class="media-body"> <div class="media-body">
<h1 class="align-self-center">${res.t('newStuff')}</h1> <h1 class="align-self-center">${res.t('newStuff')}</h1>
<h2>1/14/2019 - ${LAST_ANNOUNCEMENT_TITLE}</h2> <h2>1/18/2019 - ${LAST_ANNOUNCEMENT_TITLE}</h2>
</div> </div>
</div> </div>
<hr/> <hr/>
<div class="promo_g1g1 center-block"></div> <div class="scene_hat_guild center-block"></div>
<p>Tomorrow is your last chance to take advantage of our promotion where if you gift somebody a subscription, you get the same subscription for yourself for free!</p> <p>There's a new <a href='https://habitica.wordpress.com/2019/01/17/new-and-notable-guild-spotlight/' target='_blank'>Guild Spotlight on the blog</a> that highlights some of Habitica's new and interesting Guilds! Check it out now and find a new group where you can share your interests and goals!</p>
<p>Subscribers get tons of perks every month, including exclusive items, the ability to buy Gems with Gold, and a cute exclusive Jackalope Pet. Plus, it helps keep Habitica running :) To gift a subscription to someone, just open their profile and click on the present icon in the upper right.</p> <div class="small mb-3">by shanaqui</div>
<p>The special promotion will only run until tomorrow, so if you've been curious about trying out a subscription, now's the time! Make a friend happy and use all your new Gems to go questing together.</p>
<p>Please note that if you or your gift recipient already have a recurring subscription, the gifted subscription will only start after that subscription is cancelled or has expired. Thanks so much for your support! <3</p>
<div class="small mb-3">by SabreCat, Beffymaroo and Lemoness</div>
</div> </div>
`, `,
}); });

View File

@@ -4,6 +4,9 @@ import url from 'url';
const IS_PROD = nconf.get('IS_PROD'); const IS_PROD = nconf.get('IS_PROD');
const IGNORE_REDIRECT = nconf.get('IGNORE_REDIRECT') === 'true'; const IGNORE_REDIRECT = nconf.get('IGNORE_REDIRECT') === 'true';
const BASE_URL = nconf.get('BASE_URL'); const BASE_URL = nconf.get('BASE_URL');
// A secret key that if passed as req.query.skipSSLCheck allows to skip
// the redirects to SSL, used for health checks from the load balancer
const SKIP_SSL_CHECK_KEY = nconf.get('SKIP_SSL_CHECK_KEY');
const BASE_URL_HOST = url.parse(BASE_URL).hostname; const BASE_URL_HOST = url.parse(BASE_URL).hostname;
@@ -17,7 +20,8 @@ function isHTTP (req) {
} }
export function forceSSL (req, res, next) { export function forceSSL (req, res, next) {
if (isHTTP(req)) { const skipSSLCheck = req.query.skipSSLCheck;
if (isHTTP(req) && (!SKIP_SSL_CHECK_KEY || !skipSSLCheck || skipSSLCheck !== SKIP_SSL_CHECK_KEY)) {
return res.redirect(BASE_URL + req.originalUrl); return res.redirect(BASE_URL + req.originalUrl);
} }