gdmUtil: Add API to add/remove credential managers

Extensions don't need to poke at the internal this._credentialManagers
variable in order to add their own credential manager.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2399>
This commit is contained in:
Alessandro Bono 2022-08-03 15:34:10 +02:00 committed by Marge Bot
parent 8e081a14d5
commit b1ac1b47cd

View File

@ -179,18 +179,32 @@ var ShellUserVerifier = class extends Signals.EventEmitter {
this._unavailableServices = new Set(); this._unavailableServices = new Set();
this._credentialManagers = {}; this._credentialManagers = {};
this._credentialManagers[OVirt.SERVICE_NAME] = OVirt.getOVirtCredentialsManager();
this._credentialManagers[Vmware.SERVICE_NAME] = Vmware.getVmwareCredentialsManager();
for (let service in this._credentialManagers) { this.addCredentialManager(OVirt.SERVICE_NAME, OVirt.getOVirtCredentialsManager());
if (this._credentialManagers[service].token) { this.addCredentialManager(Vmware.SERVICE_NAME, Vmware.getVmwareCredentialsManager());
this._onCredentialManagerAuthenticated(this._credentialManagers[service], }
this._credentialManagers[service].token);
}
this._credentialManagers[service].connectObject('user-authenticated', addCredentialManager(serviceName, credentialManager) {
this._onCredentialManagerAuthenticated.bind(this), this); if (this._credentialManagers[serviceName])
return;
this._credentialManagers[serviceName] = credentialManager;
if (credentialManager.token) {
this._onCredentialManagerAuthenticated(credentialManager,
credentialManager.token);
} }
credentialManager.connectObject('user-authenticated',
this._onCredentialManagerAuthenticated.bind(this), this);
}
removeCredentialManager(serviceName) {
let credentialManager = this._credentialManagers[serviceName];
if (!credentialManager)
return;
credentialManager.disconnectObject(this);
delete this._credentialManagers[serviceName];
} }
get hasPendingMessages() { get hasPendingMessages() {
@ -262,11 +276,8 @@ var ShellUserVerifier = class extends Signals.EventEmitter {
this._smartcardManager.disconnectObject(this); this._smartcardManager.disconnectObject(this);
this._smartcardManager = null; this._smartcardManager = null;
for (let service in this._credentialManagers) { for (let service in this._credentialManagers)
let credentialManager = this._credentialManagers[service]; this.removeCredentialManager(service);
credentialManager.disconnectObject(this);
credentialManager = null;
}
} }
selectChoice(serviceName, key) { selectChoice(serviceName, key) {