Skip to content

Commit b91b1fd

Browse files
Revert "Frontend: Feature to warn users that their tokens have expired (#4494)" (#4630)
This reverts commit db88983.
1 parent 98336e0 commit b91b1fd

File tree

3 files changed

+2
-84
lines changed

3 files changed

+2
-84
lines changed

frontend/src/js/controllers/profileCtrl.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@
8888
vm.jsonResponse = response.data;
8989
vm.token = response.data['token'];
9090
vm.expiresAt = moment.utc(response.data['expires_at']).local().format("MMM D, YYYY h:mm:ss A");
91-
var expirationDateStr = response.data['expires_at'];
92-
var expirationDate = new Date(expirationDateStr);
93-
var currentDate = new Date();
94-
if (expirationDate < currentDate) {
95-
vm.showTokenExpiredDialog();
96-
}
9791
let expiresAtOffset = new Date(vm.expiresAt).getTimezoneOffset();
9892
var timezone = moment.tz.guess();
9993
vm.expiresAtTimezone = moment.tz.zone(timezone).abbr(expiresAtOffset);
@@ -189,24 +183,7 @@
189183
var urlPattern = /^(https?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w-._~:/?#[\]@!$&'()*+,;=]*)?$/;
190184
return url.length <= 200 && urlPattern.test(url);
191185
};
192-
193-
vm.showTokenExpiredDialog = function() {
194-
$mdDialog.show({
195-
templateUrl: 'dist/views/web/auth/token-expired-dialog.html',
196-
controller: ['$scope', '$mdDialog', function($scope, $mdDialog) {
197-
$scope.refreshToken = function() {
198-
$mdDialog.hide();
199-
vm.refreshToken();
200-
};
201-
202-
$scope.dismiss = function() {
203-
$mdDialog.hide();
204-
};
205-
}]
206-
});
207-
208-
};
209-
186+
210187
vm.editprofileDialog = function(ev) {
211188
switch (ev.currentTarget.id) {
212189
case "first_name":

frontend/src/views/web/auth/auth-token-expired-dialog.html

Lines changed: 0 additions & 16 deletions
This file was deleted.

frontend/tests/controllers-test/profileCtrl.test.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -349,48 +349,5 @@ describe('Unit tests for profile controller', function () {
349349
expect(result).toBeFalsy();
350350
});
351351
});
352-
353-
describe('Unit tests for showTokenExpiredDialog function', function () {
354-
beforeEach(function () {
355-
spyOn($mdDialog, 'show').and.callFake(function (options) {
356-
var fakeScope = $rootScope.$new();
357-
358-
var controllerFn = Array.isArray(options.controller)
359-
? options.controller[options.controller.length - 1]
360-
: options.controller;
361-
362-
controllerFn(fakeScope, $mdDialog);
363-
364-
expect(typeof fakeScope.refreshToken).toBe('function');
365-
expect(typeof fakeScope.dismiss).toBe('function');
366-
367-
return {
368-
then: function (confirmCallback, cancelCallback) {
369-
if (confirmCallback) confirmCallback();
370-
}
371-
};
372-
});
373-
374-
spyOn(vm, 'refreshToken'); // Spy on refreshToken to ensure it gets called
375-
});
376-
377-
it('should open token expired dialog with correct config and call refreshToken', function () {
378-
vm.showTokenExpiredDialog();
379-
380-
expect($mdDialog.show).toHaveBeenCalled();
381-
382-
var dialogArgs = $mdDialog.show.calls.mostRecent().args[0];
383-
expect(dialogArgs.templateUrl).toBe('dist/views/web/auth/token-expired-dialog.html');
384-
385-
var testScope = $rootScope.$new();
386-
var controllerFn = Array.isArray(dialogArgs.controller)
387-
? dialogArgs.controller[dialogArgs.controller.length - 1]
388-
: dialogArgs.controller;
389-
390-
controllerFn(testScope, $mdDialog);
391-
testScope.refreshToken();
392-
393-
expect(vm.refreshToken).toHaveBeenCalled();
394-
});
395-
});
352+
396353
});

0 commit comments

Comments
 (0)