authPrompt: add support for auth without username

This commit introduces a new BeginRequestType enum which gets
passed to the 'reset' signal to specify whether
a username should be provided to the begin() method and changes
the loginDialog to comply.

Currently, the signal only ever gets emitted with

AuthPrompt.BeginRequestType.PROVIDE_USERNAME

but that will change in the future when providing smartcard
support.

https://bugzilla.gnome.org/show_bug.cgi?id=683437
This commit is contained in:
Ray Strode
2013-07-28 17:49:50 -04:00
parent 1104a385fa
commit 93f072d1fc
3 changed files with 43 additions and 10 deletions

View File

@ -51,7 +51,7 @@ const UnlockDialog = new Lang.Class({
this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
this._authPrompt.connect('failed', Lang.bind(this, this._fail));
this._authPrompt.connect('cancelled', Lang.bind(this, this._fail));
this._authPrompt.setUser(this._user);
this._authPrompt.connect('reset', Lang.bind(this, this._onReset));
this._authPrompt.setPasswordChar('\u25cf');
this._authPrompt.nextButton.label = _("Unlock");
@ -75,7 +75,7 @@ const UnlockDialog = new Lang.Class({
this._otherUserButton = null;
}
this._authPrompt.begin({ userName: this._userName });
this._authPrompt.reset();
this._updateSensitivity(true);
Main.ctrlAltTabManager.addGroup(this.actor, _("Unlock Window"), 'dialog-password-symbolic');
@ -97,6 +97,18 @@ const UnlockDialog = new Lang.Class({
this.emit('failed');
},
_onReset: function(authPrompt, beginRequest) {
let userName;
if (beginRequest == AuthPrompt.BeginRequestType.PROVIDE_USERNAME) {
this._authPrompt.setUser(this._user);
userName = this._userName;
} else {
userName = null;
}
this._authPrompt.begin({ userName: userName });
},
_escape: function() {
if (this.allowCancel)
this._authPrompt.cancel();