cronapp-framework-mobile-js 3.0.0-SP.5 → 3.0.0-SP.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,10 +87,11 @@ var app = (function() {
87
87
  function ($q, $rootScope, $injector) {
88
88
  var service = {
89
89
  request: function (config) {
90
- var _u = JSON.parse(localStorage.getItem('_u'));
91
- if (_u && _u.token) {
92
- config.headers['X-AUTH-TOKEN'] = _u.token;
93
- window.uToken = _u.token;
90
+ if (!window.isUsingCookie()) {
91
+ var _u = JSON.parse(localStorage.getItem('_u'));
92
+ if (_u && _u.token) {
93
+ config.headers['X-AUTH-TOKEN'] = _u.token;
94
+ }
94
95
  }
95
96
  return config;
96
97
  },
@@ -591,6 +592,9 @@ window.refreshToken = function(Notification, $http, success, err) {
591
592
  }).success(function (data, status, headers, config) {
592
593
  // Store data response on local storage
593
594
  console.log('revive :', new Date(data.expires));
595
+ if (window.isUsingCookie()) {
596
+ delete data.token;
597
+ }
594
598
  localStorage.setItem("_u", JSON.stringify(data));
595
599
  // Recussive
596
600
  setTimeout(function () {
package/js/app.js CHANGED
@@ -60,8 +60,10 @@ var app = (function() {
60
60
  function($q, $rootScope) {
61
61
  var service = {
62
62
  'request': function(config) {
63
- var _u = JSON.parse(sessionStorage.getItem('_u'));
64
- if (_u && _u.token) config.headers['X-AUTH-TOKEN'] = _u.token;
63
+ if (!window.isUsingCookie()) {
64
+ var _u = JSON.parse(sessionStorage.getItem('_u'));
65
+ if (_u && _u.token) config.headers['X-AUTH-TOKEN'] = _u.token;
66
+ }
65
67
  return config;
66
68
  }
67
69
  };
@@ -92,6 +92,9 @@
92
92
  if ($cookies.get('_u')) {
93
93
  if (!localStorage.getItem('_u')) {
94
94
  var decodedUser = decodeURIComponent($cookies.get('_u'));
95
+ if (window.isUsingCookie()) {
96
+ delete decodedUser.token;
97
+ }
95
98
  localStorage.setItem("_u", decodedUser);
96
99
  }
97
100
  // Redirect to home page
@@ -113,7 +116,7 @@
113
116
  'Content-Type' : 'application/x-www-form-urlencoded'
114
117
  };
115
118
 
116
- if (token) {
119
+ if (!window.isUsingCookie() && token) {
117
120
  headerValues["X-AUTH-TOKEN"] = token;
118
121
  }
119
122
 
@@ -140,6 +143,9 @@
140
143
  // The session storage will be cleaned when the browser window is closed
141
144
  if(typeof (Storage) !== "undefined") {
142
145
  // save the user data on localStorage
146
+ if (window.isUsingCookie()) {
147
+ delete data.token;
148
+ }
143
149
  localStorage.setItem('_u', JSON.stringify(data));
144
150
  }
145
151
  else {
@@ -126,14 +126,17 @@
126
126
  formData.append("file", files[i]);
127
127
  }
128
128
  let _u = JSON.parse(localStorage.getItem('_u'));
129
+ let headerValues = window.isUsingCookie() ? {
130
+ 'Content-Type' : undefined
131
+ } : {
132
+ 'Content-Type' : undefined,
133
+ 'X-AUTH-TOKEN' : (_u ?_u.token : '')
134
+ };
129
135
  this.$promise = $http({
130
136
  method: 'POST',
131
137
  url: (window.hostApp || "") + uploadUrl,
132
138
  data: formData,
133
- headers: {
134
- 'Content-Type': undefined,
135
- 'X-AUTH-TOKEN': (_u ? _u.token : '')
136
- },
139
+ headers: headerValues,
137
140
  onProgress: function (event) {
138
141
  this.safeApply(function () {
139
142
  if (event.lengthComputable) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cronapp-framework-mobile-js",
3
- "version": "3.0.0-SP.5",
3
+ "version": "3.0.0-SP.50",
4
4
  "description": "Javascript library for CronApp's projects",
5
5
  "main": "cronapp.framework.mobile.js",
6
6
  "scripts": {