Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue219 #226

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions dist/ng-token-auth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports) {
module.exports = 'ng-token-auth';
}

angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
var configs, defaultConfigName;
configs = {
Expand Down Expand Up @@ -173,9 +172,9 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
confirm_success_url: successUrl,
config_name: this.getCurrentConfigName(opts.config)
});
return $http.post(this.apiUrl(opts.config) + this.getConfig(opts.config).emailRegistrationPath, params).success(function(resp) {
return $http.post(this.apiUrl(opts.config) + this.getConfig(opts.config).emailRegistrationPath, params).then(function(resp) {
return $rootScope.$broadcast('auth:registration-email-success', params);
}).error(function(resp) {
}, function(resp){
return $rootScope.$broadcast('auth:registration-email-error', resp);
});
},
Expand All @@ -184,23 +183,24 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
opts = {};
}
this.initDfd();
$http.post(this.apiUrl(opts.config) + this.getConfig(opts.config).emailSignInPath, params).success((function(_this) {

$http.post(this.apiUrl(opts.config) + this.getConfig(opts.config).emailSignInPath, params).then((function(_this)){
return function(resp) {
var authData;
_this.setConfigName(opts.config);
authData = _this.getConfig(opts.config).handleLoginResponse(resp, _this);
_this.handleValidAuth(authData);
return $rootScope.$broadcast('auth:login-success', _this.user);
};
})(this)).error((function(_this) {
}, function((function(_this)){
return function(resp) {
_this.rejectDfd({
reason: 'unauthorized',
errors: ['Invalid credentials']
});
return $rootScope.$broadcast('auth:login-error', resp);
};
})(this));
})(this))(this);
return this.dfd.promise;
},
userIsAuthenticated: function() {
Expand All @@ -216,24 +216,24 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
if (opts.config != null) {
params.config_name = opts.config;
}
return $http.post(this.apiUrl(opts.config) + this.getConfig(opts.config).passwordResetPath, params).success(function(resp) {
return $http.post(this.apiUrl(opts.config) + this.getConfig(opts.config).passwordResetPath, params).then(function(resp) {
return $rootScope.$broadcast('auth:password-reset-request-success', params);
}).error(function(resp) {
}, function(resp){
return $rootScope.$broadcast('auth:password-reset-request-error', resp);
});
},
updatePassword: function(params) {
return $http.put(this.apiUrl() + this.getConfig().passwordUpdatePath, params).success((function(_this) {
return $http.put(this.apiUrl() + this.getConfig.passwordUpdatePath, params).then((function(_this){
return function(resp) {
$rootScope.$broadcast('auth:password-change-success', resp);
return _this.mustResetPassword = false;
};
})(this)).error(function(resp) {
}, function(resp){
return $rootScope.$broadcast('auth:password-change-error', resp);
});
})(this));
},
updateAccount: function(params) {
return $http.put(this.apiUrl() + this.getConfig().accountUpdatePath, params).success((function(_this) {
return $http.put(this.apiUrl() + this.getConfig().accountUpdatePath, params).then((function(_this){
return function(resp) {
var curHeaders, key, newHeaders, updateResponse, val, _ref;
updateResponse = _this.getConfig().handleAccountUpdateResponse(resp);
Expand All @@ -252,19 +252,19 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
}
return $rootScope.$broadcast('auth:account-update-success', resp);
};
})(this)).error(function(resp) {
}, function(this){
return $rootScope.$broadcast('auth:account-update-error', resp);
});
})(this));
},
destroyAccount: function(params) {
return $http["delete"](this.apiUrl() + this.getConfig().accountUpdatePath, params).success((function(_this) {
return $http["delete"](this.apiUrl() + this.getConfig().accountUpdatePath, params).then((function(_this){
return function(resp) {
_this.invalidateTokens();
return $rootScope.$broadcast('auth:account-destroy-success', resp);
};
})(this)).error(function(resp) {
}, function(resp){
return $rootScope.$broadcast('auth:account-destroy-error', resp);
});
})(this));
},
authenticate: function(provider, opts) {
if (opts == null) {
Expand Down Expand Up @@ -483,7 +483,7 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
opts = {};
}
if (!this.tokenHasExpired()) {
return $http.get(this.apiUrl(opts.config) + this.getConfig(opts.config).tokenValidationPath).success((function(_this) {
return $http.get(this.apiUrl(opts.config) + this.getConfig(opts.config).tokenValidationPath).then((function(_this){
return function(resp) {
var authData;
authData = _this.getConfig(opts.config).handleTokenValidationResponse(resp);
Expand All @@ -499,7 +499,7 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
}
return $rootScope.$broadcast('auth:validation-success', _this.user);
};
})(this)).error((function(_this) {
}, function(function(_this){
return function(data) {
if (_this.firstTimeLogin) {
$rootScope.$broadcast('auth:email-confirmation-error', data);
Expand All @@ -513,7 +513,7 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
errors: data != null ? data.errors : ['Unspecified error']
});
};
})(this));
})(this))(this));
} else {
return this.rejectDfd({
reason: 'unauthorized',
Expand Down Expand Up @@ -544,17 +544,17 @@ angular.module('ng-token-auth', ['ipCookie']).provider('$auth', function() {
return this.deleteData('auth_headers');
},
signOut: function() {
return $http["delete"](this.apiUrl() + this.getConfig().signOutUrl).success((function(_this) {
return $http["delete"](this.apiUrl() + this.getConfig().signOutUrl).then((function(_this){
return function(resp) {
_this.invalidateTokens();
return $rootScope.$broadcast('auth:logout-success');
};
})(this)).error((function(_this) {
}, function(function(_this){
return function(resp) {
_this.invalidateTokens();
return $rootScope.$broadcast('auth:logout-error', resp);
};
})(this));
})(this))(this));
},
handleValidAuth: function(user, setHeader) {
if (setHeader == null) {
Expand Down