From dce045f0db375c71a3f614b705d29bbfd805e3f5 Mon Sep 17 00:00:00 2001 From: Findeton Date: Sat, 29 Jun 2024 08:41:26 -0500 Subject: [PATCH] wip --- avRegistration/auth-method-service.js | 68 ++++++++++++++------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/avRegistration/auth-method-service.js b/avRegistration/auth-method-service.js index d3cd6bf0..f3ad48d9 100644 --- a/avRegistration/auth-method-service.js +++ b/avRegistration/auth-method-service.js @@ -836,39 +836,41 @@ angular.module('avRegistration') .then(function(response) { var options = {}; var authToken = response.data['auth-token']; - var decodedToken = authmethod.decodeToken(authToken); - options.expires = new Date(now + 1000 * decodedToken.expiry_secs_diffs); - // update cookies expiration - $cookies.put( - "auth" + postfix, - response.data['auth-token'], - options - ); - $cookies.put( - "isAdmin" + postfix, - $cookies.get("isAdmin" + postfix), - options - ); - $cookies.put( - "userid" + postfix, - $cookies.get("userid" + postfix), - options - ); - $cookies.put( - "userid" + postfix, - $cookies.get("userid" + postfix), - options - ); - $cookies.put( - "user" + postfix, - $cookies.get("user" + postfix), - options - ); - authmethod.setAuth( - $cookies.get("auth" + postfix), - $cookies.get("isAdmin" + postfix), - autheventid - ); + if (authToken) { + var decodedToken = authmethod.decodeToken(authToken); + options.expires = new Date(now + 1000 * decodedToken.expiry_secs_diffs); + // update cookies expiration + $cookies.put( + "auth" + postfix, + response.data['auth-token'], + options + ); + $cookies.put( + "isAdmin" + postfix, + $cookies.get("isAdmin" + postfix), + options + ); + $cookies.put( + "userid" + postfix, + $cookies.get("userid" + postfix), + options + ); + $cookies.put( + "userid" + postfix, + $cookies.get("userid" + postfix), + options + ); + $cookies.put( + "user" + postfix, + $cookies.get("user" + postfix), + options + ); + authmethod.setAuth( + $cookies.get("auth" + postfix), + $cookies.get("isAdmin" + postfix), + autheventid + ); + } // if it's an election with no children elections if (angular.isDefined(response.data['vote-permission-token']))