diff --git a/static/extension/person_authentication/SuperGluuExternalAuthenticator.py b/static/extension/person_authentication/SuperGluuExternalAuthenticator.py index 7dfb64ae..30f30efa 100644 --- a/static/extension/person_authentication/SuperGluuExternalAuthenticator.py +++ b/static/extension/person_authentication/SuperGluuExternalAuthenticator.py @@ -813,7 +813,7 @@ def sendPushNotificationImpl(self, client_redirect_uri, user, super_gluu_request pushSnsService = CdiUtil.bean(PushSnsService) targetEndpointArn = self.getTargetEndpointArn(deviceRegistrationService, pushSnsService, PushPlatform.APNS, user, u2f_device) if targetEndpointArn == None: - return + return send_notification = True @@ -866,7 +866,7 @@ def sendPushNotificationImpl(self, client_redirect_uri, user, super_gluu_request pushSnsService = CdiUtil.bean(PushSnsService) targetEndpointArn = self.getTargetEndpointArn(deviceRegistrationService, pushSnsService, PushPlatform.GCM, user, u2f_device) if targetEndpointArn == None: - return + return send_notification = True @@ -904,12 +904,12 @@ def getTargetEndpointArn(self, deviceRegistrationService, pushSnsService, platfo # Return endpoint ARN if it created already notificationConf = u2fDevice.getDeviceNotificationConf() + notificationConfJson = {} if StringHelper.isNotEmpty(notificationConf): notificationConfJson = json.loads(notificationConf) - targetEndpointArn = notificationConfJson['sns_endpoint_arn'] - if StringHelper.isNotEmpty(targetEndpointArn): + if 'sns_endpoint_arn' in notificationConfJson: print "Super-Gluu. Get target endpoint ARN. There is already created target endpoint ARN" - return targetEndpointArn + return notificationConfJson['sns_endpoint_arn'] # Create endpoint ARN pushClient = None @@ -944,15 +944,16 @@ def getTargetEndpointArn(self, deviceRegistrationService, pushSnsService, platfo targetEndpointArn = registerDeviceResponse.getEndpointArn() if StringHelper.isEmpty(targetEndpointArn): - print "Super-Gluu. Failed to get endpoint ARN for user: '%s'" % user.getUserId() - return None + print "Super-Gluu. Failed to get endpoint ARN for user: '%s'" % user.getUserId() + return None print "Super-Gluu. Get target endpoint ARN. Create target endpoint ARN '%s' for user: '%s'" % (targetEndpointArn, user.getUserId()) # Store created endpoint ARN in device entry + notificationConfJson['sns_endpoint_arn'] = targetEndpointArn userInum = user.getAttribute("inum") u2fDeviceUpdate = deviceRegistrationService.findUserDeviceRegistration(userInum, u2fDevice.getId()) - u2fDeviceUpdate.setDeviceNotificationConf('{"sns_endpoint_arn" : "%s"}' % targetEndpointArn) + u2fDeviceUpdate.setDeviceNotificationConf(json.dumps(notificationConfJson)) deviceRegistrationService.updateDeviceRegistration(userInum, u2fDeviceUpdate) return targetEndpointArn