Permalink
Browse files

Merge pull request #1600 from jsbin/feature/vat

Handle VAT in upgrade
  • Loading branch information...
2 parents 2dacae3 + 6a35496 commit cec1f563dbf7df1eac60b30c550d20bf73fceec2 @remy remy committed Jul 20, 2014
@@ -0,0 +1 @@
+ALTER TABLE customers ADD COLUMN plan varchar(255);
View
@@ -91,6 +91,7 @@
"blog",
"bugs",
"business",
+ "clone",
"contacts",
"collection",
"collections",
@@ -144,6 +145,7 @@
"rules",
"runner",
"scripts",
+ "save",
"search",
"sent",
"settings",
@@ -158,6 +160,7 @@
"translate",
"trends",
"unarchive",
+ "update",
"upgrade",
"user",
"users",
View
@@ -1,3 +1,4 @@
+'use strict';
var nodemailer = require('nodemailer'),
express = require('express'),
flatten = require('flatten.js').flatten,
@@ -11,8 +12,8 @@ var nodemailer = require('nodemailer'),
routes = require('./routes'),
handlers = require('./handlers'),
middleware = require('./middleware'),
+ helpers = require('./helpers'),
metrics = require('./metrics'),
- url = require('url'),
github = require('./github')(options), // if used, contains github.id
dropbox = require('./dropbox')(options),
_ = require('underscore'),
@@ -22,7 +23,6 @@ var nodemailer = require('nodemailer'),
flattened;
function generateSessionSecret() {
- 'use strict';
console.log('Warning: Generating a session key - please see http://jsbin.com/help/session-secret');
return crypto.createHash('md5').update(Math.random() + '').digest('hex');
}
@@ -156,10 +156,7 @@ app.engine('txt', hbs.__express); // used in email
// Define some generic template variables.
-app.locals({
- version: app.get('version'),
- client: options.client,
-});
+app.locals(helpers.createHelpers(app));
app.connect = function (callback) {
app.emit('before:connect', app);
View
@@ -4,26 +4,34 @@
"user": "pro"
},
{
- "name": "Private Bins",
+ "name": "Private bins",
"user": "pro"
},
{
- "name": "Dropbox Sync",
+ "name": "SSL",
"user": "pro"
},
{
- "name": "Read & write API access",
+ "name": "Dropbox sync",
"user": "pro"
},
{
- "name": "Direct support",
+ "name": "Priority direct support",
+ "user": "pro"
+ },
+ {
+ "name": "Read & write API access (very soon)",
"user": "pro"
},
{
"name": "Asset hosting (coming soon)",
"user": "pro"
},
{
+ "name": "Full, unmodified output",
+ "user": "free"
+ },
+ {
"name": "Save bins to Gist",
"user": "free"
},
@@ -23,23 +23,23 @@
},
"pro-features": {
"title": "Pro features",
- "link": "http://jsbin.com/help/features",
+ "link": "/account/upgrade",
"data": [
{
- "title": "Sync with Dropbox",
- "link": "http://jsbin.com/help/features"
- },
- {
"title": "Private bins",
- "link": "http://jsbin.com/help/features"
+ "link": "http://jsbin.com/help/private-bins"
},
{
"title": "Vanity URLs",
- "link": "http://jsbin.com/help/features"
+ "link": "http://jsbin.com/help/pro#vanityurls"
+ },
+ {
+ "title": "SSL",
+ "link": "http://jsbin.com/help/ssl-opt-in"
},
{
- "title": "Read & write API",
- "link": "http://jsbin.com/help/features"
+ "title": "Dropbox",
+ "link": "http://jsbin.com/help/dropbox"
}
]
},
View
@@ -494,15 +494,16 @@ module.exports = utils.inherit(Object, {
var values = [
params.stripeId,
params.userId || null,
- params.user
+ params.user,
+ params.plan,
], sql = templates.setCustomer;
// not using callbacks atm
fn = fn || function() {};
this.connection.query(sql, values, function (err, result) {
if (err || !result.affectedRows) {
- return fn(err);
+ return fn(err || new Error('unable to set customer'));
}
fn(null, result);
});
@@ -529,7 +530,7 @@ module.exports = utils.inherit(Object, {
var sql = templates.getCustomerByUser;
this.connection.query(sql, [user.name], function(err, result) {
if (err || !result) {
- return fn(err);
+ return fn(err || new Error('unable to find customer'));
}
fn(null, result);
});
@@ -39,7 +39,7 @@
"isOwnerOf": "SELECT name=? as `owner`, s.active FROM `owners` AS `o`, `sandbox` AS `s` WHERE o.url=s.url AND o.revision=s.revision AND o.url=? AND o.revision=1",
"getUserBinCount": "SELECT COUNT(*) as total FROM `owners` WHERE `name`=?",
"setProAccount": "UPDATE ownership SET `pro`=?, `updated`=? WHERE `name`=?",
- "setCustomer" : "REPLACE INTO `customers` (`stripe_id`, `user_id`, `name`) VALUES (?, ?, ?)",
+ "setCustomer" : "REPLACE INTO `customers` (`stripe_id`, `user_id`, `name`, `plan`) VALUES (?, ?, ?, ?)",
"setCustomerActive": "UPDATE `customers` SET `active`=? WHERE `name`=?",
"getCustomerByStripeId": "SELECT * FROM `customers` WHERE `stripe_id`=? LIMIT 1",
"getCustomerByUser": "SELECT * FROM `customers` WHERE `name`=? LIMIT 1",
View
@@ -23,7 +23,7 @@ var Features = require('feature-gateway'),
undefsafe = require('undefsafe'),
options = require('./config');
-var teamjsbin = ['rem', 'allouis', 'yandle', 'electric_g'];
+var teamjsbin = ['allouis', 'yandle', 'electric_g', 'rem'];
var alphausers = teamjsbin.concat(['sil', 'slexaxton', 'reybango', 'phuu', 'agcolom', 'glennjones', 'rossbruniges', 'andrewnez', 'chrismahon', 'brianleroux', 'jed', 'iancrowther', 'jakearchibald']);
/* Begin: user types */
@@ -109,20 +109,18 @@ var flags = {
},
// allows the user to use jsbin entirely through SSL
- sslForAll: function (req) {
- return alpha(req) && undefsafe(req, 'session.user.settings.ssl');
+ sslForAll: function (req) { // live July 13, 2014
+ return pro(req) && undefsafe(req, 'session.user.settings.ssl');
},
fileMenuTest: true, // live 2014-05-27 - #1414
- upgrade: function (req) {
- return alpha(req); // return !pro(req);
+ upgrade: function (req) { // we're able to take payments from July 15, 2014
+ return alpha(req); // || Date.now() > new Date('2014-07-13T00:00:00').getTime();
},
// top introduction view with help and features of JS Bin
- welcomePanel: function (req) {
- return alpha(req);
- },
+ welcomePanel: alpha,
};
var features = module.exports = new Features(flags);
View
@@ -326,6 +326,15 @@ module.exports = Observable.extend({
next();
},
+ requiresLoggedIn: function (req, res, next) {
+ if (!req.session.user) {
+ req.flash(req.flash.REFERER, req.url);
+ return res.redirect('/login');
+ }
+
+ next();
+ },
+
// Routes all post requests to /sethome which needs some serious discussion
// as at the moment it uses the presence of params to determine which action
// to call. It is consistent with the PHP app though.
Oops, something went wrong.

0 comments on commit cec1f56

Please sign in to comment.