Skip to content

Commit

Permalink
Merge branch 'release/v0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
tafax committed Feb 1, 2014
2 parents 9621e86 + 0413f34 commit 0dcf0f3
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 32 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-digest-auth",
"version": "0.4.1",
"version": "0.4.2",
"main": "./dist/angular-digest-auth.min.js",
"description": "AngularJS module to manage HTTP Digest Authentication",
"repository": {
Expand Down
78 changes: 73 additions & 5 deletions dist/angular-digest-auth.dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* AngularJS module to manage HTTP Digest Authentication
* @version v0.4.1 - 2014-01-28
* @version v0.4.2 - 2014-02-01
* @link https://github.com/tafax/angular-digest-auth
* @author Matteo Tafani Alunno <matteo.tafanialunno@gmail.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -186,8 +186,9 @@ dgAuth.config(['stateMachineProvider', function(stateMachineProvider)
}
}

authIdentity.clear();
authIdentity.suspend();
authService.clearCredentials();
authStorage.clearCredentials();
var callbacksLogin = authService.getCallbacks('login.required');
for(var j in callbacksLogin)
{
Expand Down Expand Up @@ -222,7 +223,12 @@ dgAuth.config(['stateMachineProvider', function(stateMachineProvider)

if(name == 'loginRequest')
{
authIdentity.set(null, params.response.data);
if(authIdentity.isSuspended())
authIdentity.restore();

if(!authIdentity.has())
authIdentity.set(null, params.response.data);

authService.clearRequest();

var credentials = authService.getCredentials();
Expand Down Expand Up @@ -675,19 +681,33 @@ dgAuth.factory('authIdentity', function()
function AuthIdentity()
{
/**
* The current identity of user.
*
* @type {Object|null}
* @private
*/
var _identity = null;

/**
* Specifies if the identity is suspended.
*
* @type {boolean}
* @private
*/
var _suspended = false;

/**
* Sets the entire identity fields or
* if key is specified, one of these.
*
* @param {string} [key]
* @param {Object|string|Array} value
*/
this.set = function(key, value)
{
if(_suspended)
return;

if(key)
{
if(null == _identity)
Expand All @@ -705,13 +725,17 @@ dgAuth.factory('authIdentity', function()
};

/**
*
* Gets the entire identity of
* if key is specified, one single field.
*
* @param {string} [key]
* @returns {Object|Array|string|null}
*/
this.get = function(key)
{
if(_suspended)
return null;

if(!key)
return _identity;

Expand All @@ -722,21 +746,53 @@ dgAuth.factory('authIdentity', function()
};

/**
* Returns true if the identity
* is properly set.
*
* @returns {boolean}
*/
this.has = function()
{
if(_suspended)
return false;

return (null !== _identity);
};

/**
*
* Clears the identity.
*/
this.clear = function()
{
_identity = null;
};

/**
* Suspends the identity.
*/
this.suspend = function()
{
_suspended = true;
};

/**
* Restores identity that is
* previously suspended.
*/
this.restore = function()
{
_suspended = false;
};

/**
* Checks if the identity is suspended.
*
* @returns {boolean}
*/
this.isSuspended = function()
{
return _suspended;
};
}

return new AuthIdentity();
Expand Down Expand Up @@ -1080,12 +1136,24 @@ dgAuth.provider('authRequests', ['dgAuthServiceProvider', function AuthRequestsP
{
request.deferred.resolve(response);

if(_times > 0)
_times = 0;

if(stateMachine.isAvailable('201'))
stateMachine.send('201', {response: response});

return response;
},
function(response)
{
request.deferred.reject(response);

if(_times > 0)
_times = 0;

if(stateMachine.isAvailable('failure'))
stateMachine.send('failure', {response: response});

return response;
});
}
Expand Down
78 changes: 73 additions & 5 deletions dist/angular-digest-auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* AngularJS module to manage HTTP Digest Authentication
* @version v0.4.1 - 2014-01-28
* @version v0.4.2 - 2014-02-01
* @link https://github.com/tafax/angular-digest-auth
* @author Matteo Tafani Alunno <matteo.tafanialunno@gmail.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -186,8 +186,9 @@ dgAuth.config(['stateMachineProvider', function(stateMachineProvider)
}
}

authIdentity.clear();
authIdentity.suspend();
authService.clearCredentials();
authStorage.clearCredentials();
var callbacksLogin = authService.getCallbacks('login.required');
for(var j in callbacksLogin)
{
Expand Down Expand Up @@ -222,7 +223,12 @@ dgAuth.config(['stateMachineProvider', function(stateMachineProvider)

if(name == 'loginRequest')
{
authIdentity.set(null, params.response.data);
if(authIdentity.isSuspended())
authIdentity.restore();

if(!authIdentity.has())
authIdentity.set(null, params.response.data);

authService.clearRequest();

var credentials = authService.getCredentials();
Expand Down Expand Up @@ -675,19 +681,33 @@ dgAuth.factory('authIdentity', function()
function AuthIdentity()
{
/**
* The current identity of user.
*
* @type {Object|null}
* @private
*/
var _identity = null;

/**
* Specifies if the identity is suspended.
*
* @type {boolean}
* @private
*/
var _suspended = false;

/**
* Sets the entire identity fields or
* if key is specified, one of these.
*
* @param {string} [key]
* @param {Object|string|Array} value
*/
this.set = function(key, value)
{
if(_suspended)
return;

if(key)
{
if(null == _identity)
Expand All @@ -705,13 +725,17 @@ dgAuth.factory('authIdentity', function()
};

/**
*
* Gets the entire identity of
* if key is specified, one single field.
*
* @param {string} [key]
* @returns {Object|Array|string|null}
*/
this.get = function(key)
{
if(_suspended)
return null;

if(!key)
return _identity;

Expand All @@ -722,21 +746,53 @@ dgAuth.factory('authIdentity', function()
};

/**
* Returns true if the identity
* is properly set.
*
* @returns {boolean}
*/
this.has = function()
{
if(_suspended)
return false;

return (null !== _identity);
};

/**
*
* Clears the identity.
*/
this.clear = function()
{
_identity = null;
};

/**
* Suspends the identity.
*/
this.suspend = function()
{
_suspended = true;
};

/**
* Restores identity that is
* previously suspended.
*/
this.restore = function()
{
_suspended = false;
};

/**
* Checks if the identity is suspended.
*
* @returns {boolean}
*/
this.isSuspended = function()
{
return _suspended;
};
}

return new AuthIdentity();
Expand Down Expand Up @@ -1080,12 +1136,24 @@ dgAuth.provider('authRequests', ['dgAuthServiceProvider', function AuthRequestsP
{
request.deferred.resolve(response);

if(_times > 0)
_times = 0;

if(stateMachine.isAvailable('201'))
stateMachine.send('201', {response: response});

return response;
},
function(response)
{
request.deferred.reject(response);

if(_times > 0)
_times = 0;

if(stateMachine.isAvailable('failure'))
stateMachine.send('failure', {response: response});

return response;
});
}
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-digest-auth.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-digest-auth",
"version": "0.4.1",
"version": "0.4.2",
"filename": "angular-digest-auth.min.js",
"main": "./dist/angular-digest-auth.min.js",
"homepage": "https://github.com/tafax/angular-digest-auth",
Expand Down
10 changes: 8 additions & 2 deletions src/config/config-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ dgAuth.config(['stateMachineProvider', function(stateMachineProvider)
}
}

authIdentity.clear();
authIdentity.suspend();
authService.clearCredentials();
authStorage.clearCredentials();
var callbacksLogin = authService.getCallbacks('login.required');
for(var j in callbacksLogin)
{
Expand Down Expand Up @@ -153,7 +154,12 @@ dgAuth.config(['stateMachineProvider', function(stateMachineProvider)

if(name == 'loginRequest')
{
authIdentity.set(null, params.response.data);
if(authIdentity.isSuspended())
authIdentity.restore();

if(!authIdentity.has())
authIdentity.set(null, params.response.data);

authService.clearRequest();

var credentials = authService.getCredentials();
Expand Down
Loading

0 comments on commit 0dcf0f3

Please sign in to comment.