WriteOn / writeon.io

A marketing site without distraction for WriteOn
http://writeon.io
GNU General Public License v3.0
0 stars 0 forks source link

Beta account creation #28

Closed thinq4yourself closed 9 years ago

thinq4yourself commented 9 years ago

In order to properly manage beta invites, once we start to let the world know we exists, we will require a managed process in place to truly manage invitations and users.

One easy way to do this is use our existing architecture in the WriteOn app (Node/Express), Stormpath API, Mailchimp & Mandrill API, and the this Angular/Express/Node app.

Here are some docs we will need to implement:

In Express, we will create a new piece of middleware just for node-mailchimp, such as ./middleware/mailchimp.js, which will then allow us to operate the Mailchimp API internally, as well as our beta signup middleware, such as /CreateBetaAccount:

In web.js

Add this to the Node app:

app.get('/CreateBetaAccount', require('./middleware/mailchimp.js').stormpathCreate);

In ./middleware/mailchimp.js

Add this to the middleware

var request = require('request');
var CreateBetaAccount = require('mailchimp').MailChimpWebhook;
var webhook = new MailChimpWebhook();
webhook.on('error', function (error) {
    console.log(error.message);
});
webhook.on('subscribe', function (data, meta) {
    console.log(data.email+' subscribed to the WriteOn βeta'); 
   // Now, do something with user data, like this...

/* start the StormPath middleware */
exports.stormpathCreate = function(req, res) {
    var stream = req.pipe(request.post({
        uri: 'https://api.stormpath.com/v1/directories/' + req.stormPath.accountID 
        + '/accounts',
        headers: {
            'Authorization': req.headers.authorization,
            'Content-Type': 'application/json;charset=UTF-8',
            'Slug': req.headers.slug
            'username' : 'mailchimp.username',
            'email' : 'mailchimp.email',
            'givenName' : 'mailchimp.fname',
            'surname' : 'mailchimp.lname',
            'password' : 'crypto.randomizer'
        }
    }));
    stream.on('error', function(err) {
        res.send(400, err);
    });
    stream.pipe(res);
};

});

:confetti_ball: Although this is not yet usable, it's close.

Now what?

Now, we take the standard Mailchimp signup process on the website, and pre-create the beta account in the correct directory in Stormpath (βeta directory), and remove the Register option from the beta site.

Then we add a key generation flow into the creation process, where the Mailchimp final email (or Mandrill) will send the generated key (now stored in Stormpath) to the user, who can login.

There are easier ways to do this, and more economical in terms of dev resource, such as Prefinery* and Kickoff labs.

*I like Prefinery, and have always used them in the past to do this via API. The above example is a homegrown way of doing it without relying on cap limits or 3rd party API (outside already used APIs)

yaboi commented 9 years ago

Looks like a good blog post to me : ) On Jan 27, 2015 2:31 PM, "Joel Serino" notifications@github.com wrote:

In order to properly manage beta invites, once we start to let the world know we exists, we will require a managed process in place to truly manage invitations and users.

One easy way to do this is use our existing architecture in the WriteOn app (Node/Express), Stormpath API, Mailchimp & Mandrill API, and the this Angular/Express/Node app.

Here are some docs we will need to implement:

In Express, we will create a new piece of middleware just for node-mailchimp, such as ./middleware/mailchimp.js, which will then allow us to operate the Mailchimp API internally, as well as our beta signup middleware, such as /CreateBetaAccount: In web.js

Add this to the Node app:

app.get('/CreateBetaAccount', require('./middleware/mailchimp.js').stormpathCreate);

In ./middleware/mailchimp.js

Add this to the middleware

var request = require('request');var CreateBetaAccount = require('mailchimp').MailChimpWebhook;var webhook = new MailChimpWebhook(); webhook.on('error', function (error) { console.log(error.message); }); webhook.on('subscribe', function (data, meta) { console.log(data.email+' subscribed to the WriteOn βeta'); // Now, do something with user data, like this... /* start the StormPath middleware */exports.stormpathCreate = function(req, res) { var stream = req.pipe(request.post({ uri: 'https://api.stormpath.com/v1/directories/' + req.stormPath.accountID

  • '/accounts', headers: { 'Authorization': req.headers.authorization, 'Content-Type': 'application/json;charset=UTF-8', 'Slug': req.headers.slug 'username' : 'mailchimp.username', 'email' : 'mailchimp.email', 'givenName' : 'mailchimp.fname', 'surname' : 'mailchimp.lname', 'password' : 'crypto.randomizer' } })); stream.on('error', function(err) { res.send(400, err); }); stream.pipe(res); };

});

Although this is not yet usable, it's close.

— Reply to this email directly or view it on GitHub https://github.com/BeardandFedora/writeon.io/issues/28.

yaboi commented 9 years ago

bump @thinq4yourself

This should be moved over to a Trello card for further discussion about the onboarding process. We are still discussing what that process will look like, but this is a great piece of information that shouldn't be swept under the github-issue rug.