From 8e081a14d5af7c298463e1ec44906d8951148003 Mon Sep 17 00:00:00 2001 From: Alessandro Bono Date: Wed, 3 Aug 2022 15:08:07 +0200 Subject: [PATCH] gdmUtil: Collect services that determine the username in one place Doing so, extensions don't need to reimplement entirely the AuthPrompt.reset() function just for adding their own credential service in the foreground service check. Part-of: --- js/gdm/authPrompt.js | 6 +----- js/gdm/util.js | 9 +++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js index 3b1fa805a..97b12ef54 100644 --- a/js/gdm/authPrompt.js +++ b/js/gdm/authPrompt.js @@ -7,8 +7,6 @@ const Animation = imports.ui.animation; const AuthList = imports.gdm.authList; const Batch = imports.gdm.batch; const GdmUtil = imports.gdm.util; -const OVirt = imports.gdm.oVirt; -const Vmware = imports.gdm.vmware; const Params = imports.misc.params; const ShellEntry = imports.ui.shellEntry; const UserWidget = imports.ui.userWidget; @@ -630,9 +628,7 @@ var AuthPrompt = GObject.registerClass({ if (oldStatus === AuthPromptStatus.VERIFICATION_CANCELLED) return; beginRequestType = BeginRequestType.PROVIDE_USERNAME; - } else if (this._userVerifier.serviceIsForeground(OVirt.SERVICE_NAME) || - this._userVerifier.serviceIsForeground(Vmware.SERVICE_NAME) || - this._userVerifier.serviceIsForeground(GdmUtil.SMARTCARD_SERVICE_NAME)) { + } else if (this._userVerifier.foregroundServiceDeterminesUsername()) { // We don't need to know the username if the user preempted the login screen // with a smartcard or with preauthenticated oVirt credentials beginRequestType = BeginRequestType.DONT_PROVIDE_USERNAME; diff --git a/js/gdm/util.js b/js/gdm/util.js index 43647e7ac..1c2a40cd6 100644 --- a/js/gdm/util.js +++ b/js/gdm/util.js @@ -522,6 +522,15 @@ var ShellUserVerifier = class extends Signals.EventEmitter { return serviceName == this._getForegroundService(); } + foregroundServiceDeterminesUsername() { + for (let serviceName in this._credentialManagers) { + if (this.serviceIsForeground(serviceName)) + return true; + } + + return this.serviceIsForeground(SMARTCARD_SERVICE_NAME); + } + serviceIsDefault(serviceName) { return serviceName == this._defaultService; }