ui-router.grant
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "ui-router.grant", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "https://github.com/ryandrewjohnson/ui-router.grant", | ||
@@ -5,0 +5,0 @@ "authors": [ |
/** | ||
* ui-router.grant - v0.1.2 (2015-04-06) | ||
* ui-router.grant - v0.1.3 (2015-04-08) | ||
* https://github.com/ryandrewjohnson/ui-router.grant | ||
@@ -240,3 +240,3 @@ * Copyright (c) 2015 ; Licensed MIT | ||
.run(['$rootScope', '$state', 'GRANT_ERROR', function($rootScope, $state, $log, GRANT_ERROR) { | ||
.run(['$rootScope', '$state', '$log', 'GRANT_ERROR', function($rootScope, $state, $log, GRANT_ERROR) { | ||
@@ -243,0 +243,0 @@ $rootScope.$on('$stateChangeError', onStateChangeError); |
/** | ||
* ui-router.grant - v0.1.2 (2015-04-06) | ||
* ui-router.grant - v0.1.3 (2015-04-08) | ||
* https://github.com/ryandrewjohnson/ui-router.grant | ||
* Copyright (c) 2015 ; Licensed MIT | ||
*/ | ||
!function(a,b){"function"==typeof define&&define.amd?define(["angular","angular-ui-router"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("angular"),require("angular-ui-router")):angular&&b(a.angular)}(this,function(a){"use strict";a.module("ui.router.grant",["ui.router"]).constant("GRANT_ERROR","grant.rejected").provider("grant",function(){return{$get:["$q","GrantTest",function(b,c){function d(a,b){var d;if(e(a))throw new Error('grant: Unable to add test because "'+a+'" already exists!');return d=new c(a,b),k.push(d),d}function e(a){var b=k.some(function(b){return b.name===a});return b}function f(a,b){return a=i(a),h(a,b,!0)}function g(a,b){return a=i(a),h(a,b,!1)}function h(a,c,d){var e,f=[];return k.forEach(function(b){a.forEach(function(a){a.test===b.name&&(b.setStateParams(c),f.push(b.validate(a.state,d)))})}),e=b.defer(),b.all(f).then(function(a){1===a.length&&(a=a[0]),e.resolve(a)})["catch"](function(a){e.reject(a)}),e.promise}function i(b){var c;if(!a.isArray(b)&&!a.isObject(b))throw new Error("grant: invalid value provided for tests. Must be of type Array or Object.");return c=a.isArray(b)?b:[b]}var j,k;return k=[],j={only:f,except:g,addTest:d,hasTest:e}}]}}).factory("GrantTest",["$q","GRANT_ERROR",function(b,c){function d(a,b){h(a,b),this.name=a,this.validateFunction=b,this.stateParams=void 0}function e(c,d,e){var h=b.defer();return c&&a.isFunction(c.then)?(c.then(function(a){f(d,e,h,a)})["catch"](function(){g(d,e,h)}),h.promise):(c?f(d,e,h,c):g(d,e,h),h.promise)}function f(a,b,c,d){b?c.resolve(d):c.reject(a.grantFail)}function g(a,b,c){b?c.reject(a.grantFail):c.resolve()}function h(b,c){if(!a.isString(b))throw new Error("Test name must be a string");if(!a.isFunction(c))throw new Error("validationFunction must be a function")}return d.prototype.setStateParams=function(a){this.stateParams=a},d.prototype.validate=function(a,b){return this.grantFail={type:c,test:this.name,stateTo:a},e(this.validateFunction(),this,b)},d}]).run(["$rootScope","$state","GRANT_ERROR",function(a,b,c,d){function e(a,e,f,g,h,i){if(i&&i.type===d){if(i.stateTo===g)return a.preventDefault(),void c.warn('grant: test "'+i.test+'" stateTo redirect prevented. State "'+i.stateTo+'" is the current state');if(!b.get(i.stateTo))return a.preventDefault(),void c.warn('grant: test "'+i.test+'" stateTo redirect prevented. State name "'+i.stateTo+'" does not exist in ui-router $stateProvider');b.go(i.stateTo)}}a.$on("$stateChangeError",e)}])}); | ||
!function(a,b){"function"==typeof define&&define.amd?define(["angular","angular-ui-router"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("angular"),require("angular-ui-router")):angular&&b(a.angular)}(this,function(a){"use strict";a.module("ui.router.grant",["ui.router"]).constant("GRANT_ERROR","grant.rejected").provider("grant",function(){return{$get:["$q","GrantTest",function(b,c){function d(a,b){var d;if(e(a))throw new Error('grant: Unable to add test because "'+a+'" already exists!');return d=new c(a,b),k.push(d),d}function e(a){var b=k.some(function(b){return b.name===a});return b}function f(a,b){return a=i(a),h(a,b,!0)}function g(a,b){return a=i(a),h(a,b,!1)}function h(a,c,d){var e,f=[];return k.forEach(function(b){a.forEach(function(a){a.test===b.name&&(b.setStateParams(c),f.push(b.validate(a.state,d)))})}),e=b.defer(),b.all(f).then(function(a){1===a.length&&(a=a[0]),e.resolve(a)})["catch"](function(a){e.reject(a)}),e.promise}function i(b){var c;if(!a.isArray(b)&&!a.isObject(b))throw new Error("grant: invalid value provided for tests. Must be of type Array or Object.");return c=a.isArray(b)?b:[b]}var j,k;return k=[],j={only:f,except:g,addTest:d,hasTest:e}}]}}).factory("GrantTest",["$q","GRANT_ERROR",function(b,c){function d(a,b){h(a,b),this.name=a,this.validateFunction=b,this.stateParams=void 0}function e(c,d,e){var h=b.defer();return c&&a.isFunction(c.then)?(c.then(function(a){f(d,e,h,a)})["catch"](function(){g(d,e,h)}),h.promise):(c?f(d,e,h,c):g(d,e,h),h.promise)}function f(a,b,c,d){b?c.resolve(d):c.reject(a.grantFail)}function g(a,b,c){b?c.reject(a.grantFail):c.resolve()}function h(b,c){if(!a.isString(b))throw new Error("Test name must be a string");if(!a.isFunction(c))throw new Error("validationFunction must be a function")}return d.prototype.setStateParams=function(a){this.stateParams=a},d.prototype.validate=function(a,b){return this.grantFail={type:c,test:this.name,stateTo:a},e(this.validateFunction(),this,b)},d}]).run(["$rootScope","$state","$log","GRANT_ERROR",function(a,b,c,d){function e(a,e,f,g,h,i){if(i&&i.type===d){if(i.stateTo===g)return a.preventDefault(),void c.warn('grant: test "'+i.test+'" stateTo redirect prevented. State "'+i.stateTo+'" is the current state');if(!b.get(i.stateTo))return a.preventDefault(),void c.warn('grant: test "'+i.test+'" stateTo redirect prevented. State name "'+i.stateTo+'" does not exist in ui-router $stateProvider');b.go(i.stateTo)}}a.$on("$stateChangeError",e)}])}); |
@@ -40,3 +40,3 @@ 'use strict'; | ||
port: 9000, | ||
base: ['demo', 'src'], | ||
base: ['demo', 'dist'], | ||
keepalive : true, | ||
@@ -43,0 +43,0 @@ open: true |
{ | ||
"name": "ui-router.grant", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Protect your ui-router routes with the easy to use grant module.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -235,3 +235,3 @@ (function (root, factory) { | ||
.run(['$rootScope', '$state', 'GRANT_ERROR', function($rootScope, $state, $log, GRANT_ERROR) { | ||
.run(['$rootScope', '$state', '$log', 'GRANT_ERROR', function($rootScope, $state, $log, GRANT_ERROR) { | ||
@@ -238,0 +238,0 @@ $rootScope.$on('$stateChangeError', onStateChangeError); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58771