Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/shadowfax-http
Angular HTTP service for shadowfax login forms.
https://github.com/binocarlos/shadowfax-http
Last synced: 11 days ago
JSON representation
Angular HTTP service for shadowfax login forms.
- Host: GitHub
- URL: https://github.com/binocarlos/shadowfax-http
- Owner: binocarlos
- License: mit
- Created: 2014-10-07T19:08:45.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-08T18:14:39.000Z (about 10 years ago)
- Last Synced: 2024-10-06T11:45:16.162Z (about 1 month ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
shadowfax-http
==============Angular HTTP service for [shadowfax](https://github.com/binocarlos/shadowfax) login forms.
Connects to a REST based backend to perform login/register actions - [gandalf](https://github.com/binocarlos/gandalf) will work out of the box.
## install
Install the module to your project:
```
$ npm install shadowfax-http --save
```## usage
Create a new handler by passing in a $scope that contain some shadowfax directives:
```js
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](https://github.com/substack/node-browserify) and [brfs](https://github.com/substack/brfs):
```bash
$ browserify app.js > bundle.js
```## license
MIT