Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
vlavrynovych committed Aug 16, 2017
2 parents e970b7c + 72e3c1b commit 5252289
Show file tree
Hide file tree
Showing 28 changed files with 1,425 additions and 248 deletions.
64 changes: 3 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
[![Bower](https://img.shields.io/bower/v/angular-spa-auth.svg)]()
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status](https://travis-ci.org/vlavrynovych/angular-spa-auth.svg?branch=master)](https://travis-ci.org/vlavrynovych/angular-spa-auth)
[![Coverage Status](https://coveralls.io/repos/github/vlavrynovych/angular-spa-auth/badge.svg?branch=master)](https://coveralls.io/github/vlavrynovych/angular-spa-auth?branch=develop)

[![NPM](https://nodei.co/npm/angular-spa-auth.png?downloads=true)](https://nodei.co/npm/angular-spa-auth/)

[npm-image]: https://img.shields.io/npm/v/angular-spa-auth.svg?style=flat
[npm-url]: https://npmjs.org/package/angular-spa-auth
[downloads-image]: https://img.shields.io/npm/dm/angular-spa-auth.svg?style=flat
[downloads-url]: https://npmjs.org/package/angular-spa-auth
<!--[travis-image]: https://travis-ci.org/UnbounDev/angular-spa-auth.svg?branch=master&style=flat-->
<!--[travis-url]: https://travis-ci.org/UnbounDev/angular-spa-auth-->

Frontend module that provides ability to easily handle most of the logic related to
the authentication process and route change for the [AngularJS](https://angularjs.org/)
Expand Down Expand Up @@ -47,7 +46,6 @@ the authentication process and route change for the [AngularJS](https://angularj
- [#logout()](#logout-handler)
- [#success(data)](#success-handler)
- [#error(err)](#error-handler)
- [Mixins](#mixins)
- [AuthService](#authservice)
- [#run(config)](#run-method)
- [#login(credentials)](#login-method)
Expand All @@ -61,14 +59,12 @@ the authentication process and route change for the [AngularJS](https://angularj
- [#openTarget()](#opentarget-method)
- [#openLogin()](#openlogin-method)
- [#openHome()](#openhome-method)
- [Mixins Methods](#mixins-methods)
- [License](#license)

# Features
- Handles for you all the work related to authentication process and route change
- Saves original/target route and redirects user to it after login/authentication check
- Very customizable and flexible
- Has ability to extend [AuthService](#authservice) using your own methods - [mixins](#mixins)
- Works perfect with both: [**angular-route**](https://www.npmjs.com/package/angular-route)
([**ngRoute**](https://www.npmjs.com/package/angular-route)) and
[**angular-route-segment**](http://angular-route-segment.com/).
Expand Down Expand Up @@ -140,13 +136,6 @@ First of all you have to pass `config` object to the [AuthService#run](#run-meth
error: function () {
toastr.error('Unable to authenticate.');
}
},
mixins: {
find: function (id) {
return $http.get('/auth/find?id=' + id).then(function (response) {
return response.data;
});
}
}
});
}]);
Expand All @@ -158,11 +147,10 @@ The `config` object have different field for customizing you authentication proc
| Name | Type | Description |
|:----:|:----:|:------------|
| [verbose](#verbose) | `Boolean` | Activates `console.info` output if true |
| [publicUrls](#public-urls) | `Array<String>` | List url that are available for unauthorized users |
| [publicUrls](#public-urls) | `Array<String|RegExp>` | List urls that are available for unauthorized users |
| [endpoints](#endpoints) | `Object` | Gives you ability to setup all the backed endpoints that will own roles in the authentication process |
| [uiRoutes](#ui-routes) | `Object` | Helps you automatically redirect user to the specified UI routes such as `home` and `login` |
| [handlers](#handlers) | `Object` | Allows you to provide you implementation for key methods of authentication process |
| [mixins](#mixins) | `Object` | Allows you to extend [`AuthService`](#authservice) |

### Verbose
For development perspective you can enable **console.info** message using `verbose` parameter
Expand All @@ -187,7 +175,7 @@ Public urls is a list of urls that available for all unauthorized users.
```js
AuthService.run({
...
publicUrls: ['/login', '/home', '/registration', '/confirmation', '/forgotPassword'],
publicUrls: ['/login', '/home', '/registration', /public/, '/confirmation', '/forgotPassword', /^\/manage\/.*$/],
...
})
```
Expand Down Expand Up @@ -548,45 +536,6 @@ AuthService.run({
})
```

### Mixins

All the methods that are added using `mixins` property of `config` object
will be available in the `AuthService` as its own methods.

###### Example

**app.run.js**

```js
angular
.module('app')
.run(['AuthService', function (AuthService) {
var config = {...}
AuthService.run({
mixins: {
customMethod: function() {
...
// your logic here
...
}
}
});
}]);
```

**main.controller.js**

```js
angular
.module('app')
.controller('MainController', ['$scope', 'AuthService', function ($scope, AuthService) {
AuthService.customMethod();
}]);
```

**Note:** you cannot override native methods of the `AuthService`
(e.g. [`AuthService#login`](#login-method))

## AuthService
This `angular-spa-auth` module supplies `AuthService` which can be injected
in any place of the project allowed by AngularJS
Expand All @@ -608,7 +557,6 @@ Public methods:
- [#openTarget()](#opentarget-method)
- [#openLogin()](#openlogin-method)
- [#openHome()](#openhome-method)
- [Mixins Methods](#mixins-methods)


### run method
Expand Down Expand Up @@ -754,12 +702,6 @@ Redirects user to the home page
AuthService.openHome()
```

### Mixins Methods

You can extend `AuthService` using mixins.

For more details please see the [Mixins](#mixins) section

# License

The MIT License (MIT)
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Volodymyr Lavrynovych <volodyalavrynovych@gmail.com>"
],
"version": "0.6.0",
"version": "0.7.0",
"description": "Provides ability to easily handle most of the logic related to the authentication process and page load for the AngularJS SPA",
"main": "dist/angular-spa-auth.min.js",
"keywords": [
Expand Down
Loading

0 comments on commit 5252289

Please sign in to comment.