Skip to content

Commit abb54f0

Browse files
committed
v1.2.3
1 parent 35ca191 commit abb54f0

File tree

7 files changed

+75
-75
lines changed

7 files changed

+75
-75
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-authenticate",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"main": "dist/vue-authenticate.js",
55
"homepage": "https://github.com/dgrubelic/vue-authenticate",
66
"ignore": [

dist/vue-authenticate.common.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-authenticate v1.2.2
2+
* vue-authenticate v1.2.3
33
* https://github.com/dgrubelic/vue-authenticate
44
* Released under the MIT License.
55
*/
@@ -1011,15 +1011,19 @@ var VueAuthenticate = function VueAuthenticate($http, overrideOptions) {
10111011
});
10121012

10131013
// Setup request interceptors
1014-
if (this.options.bindRequestInterceptor && isFunction(this.options.bindRequestInterceptor)) {
1015-
this.options.bindRequestInterceptor.call(this);
1014+
if (this.options.bindRequestInterceptor && isFunction(this.options.bindRequestInterceptor) &&
1015+
this.options.bindResponseInterceptor && isFunction(this.options.bindResponseInterceptor)) {
10161016

1017-
if (this.options.bindResponseInterceptor && isFunction(this.options.bindResponseInterceptor)) {
1018-
this.options.bindResponseInterceptor.call(this);
1019-
}
1017+
this.options.bindRequestInterceptor.call(this);
1018+
this.options.bindResponseInterceptor.call(this);
10201019
} else {
1021-
// By default, insert request interceptor for vue-resource
1022-
this.$http.interceptors.push(function (request, next) {
1020+
// Check if vue-resource is found
1021+
if (!Vue && !Vue.http && !Vue.http.interceptors) {
1022+
throw new Error('vue-resource library not found')
1023+
}
1024+
1025+
// By default, request and response interceptors are for vue-resource
1026+
Vue.http.interceptors.push(function (request, next) {
10231027
if (this$1.isAuthenticated()) {
10241028
request.headers.set('Authorization', [
10251029
this$1.options.tokenType, this$1.getToken()
@@ -1028,21 +1032,17 @@ var VueAuthenticate = function VueAuthenticate($http, overrideOptions) {
10281032
request.headers.delete('Authorization');
10291033
}
10301034

1031-
if (this$1.options.bindResponseInterceptor && isFunction(this$1.options.bindResponseInterceptor)) {
1032-
this$1.options.bindResponseInterceptor.call(this$1);
1033-
} else {
1034-
next(function (response) {
1035-
try {
1036-
var responseJson = JSON.parse(response[this$1.options.responseDataKey]);
1037-
if (responseJson[this$1.options.tokenName]) {
1038-
this$1.setToken(responseJson);
1039-
delete responseJson[this$1.options.tokenName];
1040-
return responseJson
1041-
}
1042-
} catch(e) {}
1043-
return response
1044-
});
1045-
}
1035+
next(function (response) {
1036+
try {
1037+
var responseJson = JSON.parse(response[this$1.options.responseDataKey]);
1038+
if (responseJson[this$1.options.tokenName]) {
1039+
this$1.setToken(responseJson);
1040+
delete responseJson[this$1.options.tokenName];
1041+
return responseJson
1042+
}
1043+
} catch(e) {}
1044+
return response
1045+
});
10461046
});
10471047
}
10481048
};

dist/vue-authenticate.es2015.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-authenticate v1.2.2
2+
* vue-authenticate v1.2.3
33
* https://github.com/dgrubelic/vue-authenticate
44
* Released under the MIT License.
55
*/
@@ -1009,15 +1009,19 @@ var VueAuthenticate = function VueAuthenticate($http, overrideOptions) {
10091009
});
10101010

10111011
// Setup request interceptors
1012-
if (this.options.bindRequestInterceptor && isFunction(this.options.bindRequestInterceptor)) {
1013-
this.options.bindRequestInterceptor.call(this);
1012+
if (this.options.bindRequestInterceptor && isFunction(this.options.bindRequestInterceptor) &&
1013+
this.options.bindResponseInterceptor && isFunction(this.options.bindResponseInterceptor)) {
10141014

1015-
if (this.options.bindResponseInterceptor && isFunction(this.options.bindResponseInterceptor)) {
1016-
this.options.bindResponseInterceptor.call(this);
1017-
}
1015+
this.options.bindRequestInterceptor.call(this);
1016+
this.options.bindResponseInterceptor.call(this);
10181017
} else {
1019-
// By default, insert request interceptor for vue-resource
1020-
this.$http.interceptors.push(function (request, next) {
1018+
// Check if vue-resource is found
1019+
if (!Vue && !Vue.http && !Vue.http.interceptors) {
1020+
throw new Error('vue-resource library not found')
1021+
}
1022+
1023+
// By default, request and response interceptors are for vue-resource
1024+
Vue.http.interceptors.push(function (request, next) {
10211025
if (this$1.isAuthenticated()) {
10221026
request.headers.set('Authorization', [
10231027
this$1.options.tokenType, this$1.getToken()
@@ -1026,21 +1030,17 @@ var VueAuthenticate = function VueAuthenticate($http, overrideOptions) {
10261030
request.headers.delete('Authorization');
10271031
}
10281032

1029-
if (this$1.options.bindResponseInterceptor && isFunction(this$1.options.bindResponseInterceptor)) {
1030-
this$1.options.bindResponseInterceptor.call(this$1);
1031-
} else {
1032-
next(function (response) {
1033-
try {
1034-
var responseJson = JSON.parse(response[this$1.options.responseDataKey]);
1035-
if (responseJson[this$1.options.tokenName]) {
1036-
this$1.setToken(responseJson);
1037-
delete responseJson[this$1.options.tokenName];
1038-
return responseJson
1039-
}
1040-
} catch(e) {}
1041-
return response
1042-
});
1043-
}
1033+
next(function (response) {
1034+
try {
1035+
var responseJson = JSON.parse(response[this$1.options.responseDataKey]);
1036+
if (responseJson[this$1.options.tokenName]) {
1037+
this$1.setToken(responseJson);
1038+
delete responseJson[this$1.options.tokenName];
1039+
return responseJson
1040+
}
1041+
} catch(e) {}
1042+
return response
1043+
});
10441044
});
10451045
}
10461046
};

dist/vue-authenticate.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-authenticate v1.2.2
2+
* vue-authenticate v1.2.3
33
* https://github.com/dgrubelic/vue-authenticate
44
* Released under the MIT License.
55
*/
@@ -1015,15 +1015,19 @@ var VueAuthenticate = function VueAuthenticate($http, overrideOptions) {
10151015
});
10161016

10171017
// Setup request interceptors
1018-
if (this.options.bindRequestInterceptor && isFunction(this.options.bindRequestInterceptor)) {
1019-
this.options.bindRequestInterceptor.call(this);
1018+
if (this.options.bindRequestInterceptor && isFunction(this.options.bindRequestInterceptor) &&
1019+
this.options.bindResponseInterceptor && isFunction(this.options.bindResponseInterceptor)) {
10201020

1021-
if (this.options.bindResponseInterceptor && isFunction(this.options.bindResponseInterceptor)) {
1022-
this.options.bindResponseInterceptor.call(this);
1023-
}
1021+
this.options.bindRequestInterceptor.call(this);
1022+
this.options.bindResponseInterceptor.call(this);
10241023
} else {
1025-
// By default, insert request interceptor for vue-resource
1026-
this.$http.interceptors.push(function (request, next) {
1024+
// Check if vue-resource is found
1025+
if (!Vue && !Vue.http && !Vue.http.interceptors) {
1026+
throw new Error('vue-resource library not found')
1027+
}
1028+
1029+
// By default, request and response interceptors are for vue-resource
1030+
Vue.http.interceptors.push(function (request, next) {
10271031
if (this$1.isAuthenticated()) {
10281032
request.headers.set('Authorization', [
10291033
this$1.options.tokenType, this$1.getToken()
@@ -1032,21 +1036,17 @@ var VueAuthenticate = function VueAuthenticate($http, overrideOptions) {
10321036
request.headers.delete('Authorization');
10331037
}
10341038

1035-
if (this$1.options.bindResponseInterceptor && isFunction(this$1.options.bindResponseInterceptor)) {
1036-
this$1.options.bindResponseInterceptor.call(this$1);
1037-
} else {
1038-
next(function (response) {
1039-
try {
1040-
var responseJson = JSON.parse(response[this$1.options.responseDataKey]);
1041-
if (responseJson[this$1.options.tokenName]) {
1042-
this$1.setToken(responseJson);
1043-
delete responseJson[this$1.options.tokenName];
1044-
return responseJson
1045-
}
1046-
} catch(e) {}
1047-
return response
1048-
});
1049-
}
1039+
next(function (response) {
1040+
try {
1041+
var responseJson = JSON.parse(response[this$1.options.responseDataKey]);
1042+
if (responseJson[this$1.options.tokenName]) {
1043+
this$1.setToken(responseJson);
1044+
delete responseJson[this$1.options.tokenName];
1045+
return responseJson
1046+
}
1047+
} catch(e) {}
1048+
return response
1049+
});
10501050
});
10511051
}
10521052
};

dist/vue-authenticate.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/vue-authenticate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-authenticate v1.2.2
2+
* vue-authenticate v1.2.3
33
* https://github.com/dgrubelic/vue-authenticate
44
* Released under the MIT License.
55
*/

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "vue-authenticate",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "Authentication library for Vue.js",
55
"main": "dist/vue-authenticate.js",
66
"module": "dist/vue-authenticate.es2015.js",
77
"unpkg": "dist/vue-authenticate.js",
88
"scripts": {
99
"dev": "parallelshell \"node-dev ./example/server.js\" \"gulp dev\"",
10-
"build": "node build/build.js"
10+
"build": "node build/build.js && cp ./dist/vue-authenticate.js ./example/"
1111
},
1212
"keywords": [
1313
"vue",

0 commit comments

Comments
 (0)