/notum

Add protected / public routes to Marionette AppRouter

Primary LanguageJavaScript

Notum


Codeship Status for peeter-tomberg/notum

Notum enables you to have protected / public routes in your application. If you wish to disable protection on a route, please check Public routes

Installation

bower install notum

Setup requirejs

    var requirejs = {
        "paths": {
            "Notum" : "bower_components/notum/src",
            "underscore" : "bower_components/underscore/underscore"
        }
    };

Setup

    var Backbone = require('backbone');
    var Notum = require('Notum/Notum');
    
    var unauthorized = function () {
        logger.info('Unauthorized')
        app.execute('navigate:login');
    };

    var notum = new Notum({
        backbone : Backbone,
        callback : unauthorized,
        authorized : false
    });
    notum.wrap(); //Needs to be called before you create your routers

After login

    if (!notum.resume()) {
        app.execute('navigate:home');
    }

Public routes

    var Router = Marionette.AppRouter.extend({

        isProtected : false,

        appRoutes: {
            'home' : 'index'
        }
    });