vladikoff / meteor-accounts-persona

Login service for Mozilla Persona accounts
MIT License
19 stars 6 forks source link

meteor-accounts-persona

A meteor package for Mozilla Persona, the decentralized authentication system.

See Demo App (View Source)

Watch Quick Setup Tutorial

View package in the Atmosphere package repository

Package Dependencies

Install

mrt add accounts-persona

mrt is a Meteorite command line tool. Visit Meteorite's page to learn more.

Include Persona Library

Since version 0.1.3 this package requires you to include the Persona library yourself, please read below.

Mozilla strongly recommends directly downloading the persona library from their servers due to possible changes, and Meteor does not allow dynamically loading remote JavaScript files. To meet both requirements you MUST include the Persona library in your head section. To do this, in one template file, add the following code:

<head>
    <script>
        (function() {
            var t   = document.createElement('script');
            t.type  = 'text/javascript';
            t.async = true;
            t.id    = 'persona-lib';
            t.src = '//login.persona.org/include.js';
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(t, s);
        })();
    </script>
</head>

The code will load the persona library directly from Mozilla without blocking the rest of the page loading.

Usage

If you use {{loginButtons}} from accounts-ui, then "Sign in with Persona" will show up right after you install this package. (NOTE: to use {{loginButtons}} make sure you have accounts-ui added)

To create a custom login button, use an event handler:

Template.header.events({
    'click #loginPersona': function () {
            Meteor.loginWithPersona();
    }
});

You can download the official Persona Buttons from Persona Branding Resources

Meteor.loginWithPersona(); supports Meteor.loginWithExternalService([options], [callback])

FAQ

See the Github Wiki for FAQ