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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2399>
This commit is contained in:
Alessandro Bono 2022-08-03 15:08:07 +02:00 committed by Marge Bot
parent 9671eb3ad8
commit 8e081a14d5
2 changed files with 10 additions and 5 deletions

View File

@ -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;

View File

@ -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;
}