Skip to content

drop-in authentication module (login view included) using requirejs and backbone marionette modules to handle 401 and 403 http codes

Notifications You must be signed in to change notification settings

gins0023/marionette-requirejs-auth-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Backbone.Marionette + RequireJS Authentication Module

This module allows you to handle authentication against your api. Check out main.js for require config setup as well as js/app.js to see how the module itself is included with the mandatory arguments. Additional arguments are possible for more customization.

##Example

define(["jquery", "underscore", "backbone", "marionette"], function($, _, Backbone, Marionette) {
	var App = new Marionette.Application();

	App.addRegions({
		headerRegion: "#header-region",
		mainRegion: "#main-region"
	});

	App.on("initialize:after", function() {
		if (Backbone.history) {
			require(["AuthenticationModule/app"], function(AuthApp) {
				Backbone.history.start();

				AuthApp.start({
					loginUrl: 'http://127.0.0.1/login',
					logoutUrl: 'http://127.0.0.1/logout',
					appRegion: 'mainRegion'
				});
				
				//test auth module
				/*$.ajax({
					type: 'get',
					url: 'http://127.0.0.1/SOME_ENDPOINT_THAT_RETURNS_401'
				});*/
			});
		}
	});

	return App;
});

About

drop-in authentication module (login view included) using requirejs and backbone marionette modules to handle 401 and 403 http codes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published