shadowfax-http
v0.1.0
Published
Event handler for shadowfax forms that posts data to a gandalf server
Downloads
1
Maintainers
Readme
shadowfax-http
Angular HTTP service for shadowfax login forms.
Connects to a REST based backend to perform login/register actions - gandalf will work out of the box.
install
Install the module to your project:
$ npm install binocarlos/shadowfax-http --save
usage
Create a new handler by passing in a $scope that contain some shadowfax directives:
var angular = require('angular-bsfy')
var shadowfax = require('shadowfax')
var shadowfaxhttp = require('shadowfax-http')
var app = angular.module('myApp',[
shadowfax.name,
shadowfaxhttp.name
])
.controller('LoginPage', function($scope, shadowfaxhttp){
// listen to the shadowfax form events and dispatch
// them to the given urls
shadowfaxhttp($scope, {
login:'/auth/login',
register:'/auth/register'
})
// triggered if the user has logged in or registered with no problems
$scope.$on('shadowfax:complete', function($ev, type){
// type is a string 'login' or 'register'
if(type=='login'){
document.location = '/dashboard'
}
else{
document.location = '/postregister'
}
})
// display a login error (like incorrect password)
$scope.$on('shadowfax:error', function($ev, type, error){
// type is 'login' or 'register' or 'save'
})
// display general information
$scope.$on('shadowfax:message', function($ev, type, error){
// type is 'login' or 'register' or 'save'
})
})
build
Then compile with browserify and brfs:
$ browserify app.js > bundle.js
license
MIT