2013-07-24 00:37:42 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-07-16 09:24:13 +00:00
|
|
|
/* exported AuthPrompt */
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2021-04-13 14:59:49 +00:00
|
|
|
const { Clutter, GLib, GObject, Pango, Shell, St } = imports.gi;
|
2013-07-24 00:37:42 +00:00
|
|
|
|
|
|
|
const Animation = imports.ui.animation;
|
2017-07-17 20:48:03 +00:00
|
|
|
const AuthList = imports.gdm.authList;
|
2013-07-22 15:07:35 +00:00
|
|
|
const Batch = imports.gdm.batch;
|
|
|
|
const GdmUtil = imports.gdm.util;
|
2020-08-17 21:41:04 +00:00
|
|
|
const OVirt = imports.gdm.oVirt;
|
2020-09-21 14:11:41 +00:00
|
|
|
const Vmware = imports.gdm.vmware;
|
2013-07-22 15:07:35 +00:00
|
|
|
const Params = imports.misc.params;
|
2013-07-24 00:37:42 +00:00
|
|
|
const ShellEntry = imports.ui.shellEntry;
|
|
|
|
const UserWidget = imports.ui.userWidget;
|
2020-08-17 21:41:04 +00:00
|
|
|
const Util = imports.misc.util;
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var DEFAULT_BUTTON_WELL_ICON_SIZE = 16;
|
2019-08-01 23:13:10 +00:00
|
|
|
var DEFAULT_BUTTON_WELL_ANIMATION_DELAY = 1000;
|
|
|
|
var DEFAULT_BUTTON_WELL_ANIMATION_TIME = 300;
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2019-08-01 23:13:10 +00:00
|
|
|
var MESSAGE_FADE_OUT_ANIMATION_TIME = 500;
|
2013-07-24 14:53:48 +00:00
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var AuthPromptMode = {
|
2013-07-22 15:07:35 +00:00
|
|
|
UNLOCK_ONLY: 0,
|
2019-08-20 21:43:54 +00:00
|
|
|
UNLOCK_OR_LOG_IN: 1,
|
2013-07-22 15:07:35 +00:00
|
|
|
};
|
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var AuthPromptStatus = {
|
2013-07-28 20:24:31 +00:00
|
|
|
NOT_VERIFYING: 0,
|
|
|
|
VERIFYING: 1,
|
|
|
|
VERIFICATION_FAILED: 2,
|
2019-08-20 21:43:54 +00:00
|
|
|
VERIFICATION_SUCCEEDED: 3,
|
2021-01-30 03:18:32 +00:00
|
|
|
VERIFICATION_CANCELLED: 4,
|
2021-02-01 12:10:45 +00:00
|
|
|
VERIFICATION_IN_PROGRESS: 5,
|
2013-07-28 20:24:31 +00:00
|
|
|
};
|
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var BeginRequestType = {
|
2013-07-28 21:49:50 +00:00
|
|
|
PROVIDE_USERNAME: 0,
|
2019-08-20 21:43:54 +00:00
|
|
|
DONT_PROVIDE_USERNAME: 1,
|
2021-02-01 12:10:45 +00:00
|
|
|
REUSE_USERNAME: 2,
|
2013-07-28 21:49:50 +00:00
|
|
|
};
|
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
var AuthPrompt = GObject.registerClass({
|
|
|
|
Signals: {
|
|
|
|
'cancelled': {},
|
|
|
|
'failed': {},
|
|
|
|
'next': {},
|
|
|
|
'prompted': {},
|
|
|
|
'reset': { param_types: [GObject.TYPE_UINT] },
|
2019-08-20 21:43:54 +00:00
|
|
|
},
|
2019-07-16 09:24:13 +00:00
|
|
|
}, class AuthPrompt extends St.BoxLayout {
|
|
|
|
_init(gdmClient, mode) {
|
|
|
|
super._init({
|
|
|
|
style_class: 'login-dialog-prompt-layout',
|
2019-08-20 21:43:54 +00:00
|
|
|
vertical: true,
|
2020-01-14 14:53:36 +00:00
|
|
|
x_expand: true,
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
2022-01-25 17:09:05 +00:00
|
|
|
reactive: true,
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|
|
|
|
|
2013-07-28 20:24:31 +00:00
|
|
|
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
|
2013-07-22 15:07:35 +00:00
|
|
|
|
|
|
|
this._gdmClient = gdmClient;
|
|
|
|
this._mode = mode;
|
2020-02-20 14:57:36 +00:00
|
|
|
this._defaultButtonWellActor = null;
|
2021-02-01 12:10:45 +00:00
|
|
|
this._cancelledRetries = 0;
|
2013-07-22 15:07:35 +00:00
|
|
|
|
|
|
|
let reauthenticationOnly;
|
|
|
|
if (this._mode == AuthPromptMode.UNLOCK_ONLY)
|
|
|
|
reauthenticationOnly = true;
|
|
|
|
else if (this._mode == AuthPromptMode.UNLOCK_OR_LOG_IN)
|
|
|
|
reauthenticationOnly = false;
|
|
|
|
|
2019-08-19 19:06:04 +00:00
|
|
|
this._userVerifier = new GdmUtil.ShellUserVerifier(this._gdmClient, { reauthenticationOnly });
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
this._userVerifier.connect('ask-question', this._onAskQuestion.bind(this));
|
|
|
|
this._userVerifier.connect('show-message', this._onShowMessage.bind(this));
|
2017-07-17 20:48:03 +00:00
|
|
|
this._userVerifier.connect('show-choice-list', this._onShowChoiceList.bind(this));
|
2017-12-02 00:27:35 +00:00
|
|
|
this._userVerifier.connect('verification-failed', this._onVerificationFailed.bind(this));
|
|
|
|
this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
|
|
|
|
this._userVerifier.connect('reset', this._onReset.bind(this));
|
|
|
|
this._userVerifier.connect('smartcard-status-changed', this._onSmartcardStatusChanged.bind(this));
|
2020-01-03 16:31:15 +00:00
|
|
|
this._userVerifier.connect('credential-manager-authenticated', this._onCredentialManagerAuthenticated.bind(this));
|
2013-06-27 12:54:19 +00:00
|
|
|
this.smartcardDetected = this._userVerifier.smartcardDetected;
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2019-10-21 18:44:00 +00:00
|
|
|
this._userWell = new St.Bin({
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
});
|
|
|
|
this.add_child(this._userWell);
|
2019-12-12 09:32:53 +00:00
|
|
|
|
2020-02-18 21:23:26 +00:00
|
|
|
this._hasCancelButton = this._mode === AuthPromptMode.UNLOCK_OR_LOG_IN;
|
2020-02-14 16:14:55 +00:00
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
this._initInputRow();
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2020-02-14 20:10:04 +00:00
|
|
|
let capsLockPlaceholder = new St.Label();
|
|
|
|
this.add_child(capsLockPlaceholder);
|
|
|
|
|
2020-02-05 18:26:44 +00:00
|
|
|
this._capsLockWarningLabel = new ShellEntry.CapsLockWarning({
|
|
|
|
x_expand: true,
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
2019-12-17 20:03:45 +00:00
|
|
|
this.add_child(this._capsLockWarningLabel);
|
|
|
|
|
2020-02-14 20:10:04 +00:00
|
|
|
this._capsLockWarningLabel.bind_property('visible',
|
|
|
|
capsLockPlaceholder, 'visible',
|
|
|
|
GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.INVERT_BOOLEAN);
|
|
|
|
|
2019-10-21 18:44:00 +00:00
|
|
|
this._message = new St.Label({
|
|
|
|
opacity: 0,
|
|
|
|
styleClass: 'login-dialog-message',
|
|
|
|
y_expand: true,
|
2020-02-05 18:26:44 +00:00
|
|
|
x_expand: true,
|
2019-10-21 18:44:00 +00:00
|
|
|
y_align: Clutter.ActorAlign.START,
|
2020-02-05 18:26:44 +00:00
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
2019-10-21 18:44:00 +00:00
|
|
|
});
|
2013-07-28 16:40:55 +00:00
|
|
|
this._message.clutter_text.line_wrap = true;
|
2016-10-13 04:29:21 +00:00
|
|
|
this._message.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
2019-10-21 18:44:00 +00:00
|
|
|
this.add_child(this._message);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onDestroy() {
|
2014-10-09 18:10:12 +00:00
|
|
|
this._userVerifier.destroy();
|
2013-07-29 17:24:36 +00:00
|
|
|
this._userVerifier = null;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2019-09-10 05:42:48 +00:00
|
|
|
vfunc_key_press_event(keyPressEvent) {
|
|
|
|
if (keyPressEvent.keyval == Clutter.KEY_Escape)
|
|
|
|
this.cancel();
|
2020-03-26 22:40:38 +00:00
|
|
|
return super.vfunc_key_press_event(keyPressEvent);
|
2019-09-10 05:42:48 +00:00
|
|
|
}
|
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
_initInputRow() {
|
2020-01-14 19:02:24 +00:00
|
|
|
this._mainBox = new St.BoxLayout({
|
|
|
|
style_class: 'login-dialog-button-box',
|
|
|
|
vertical: false,
|
|
|
|
});
|
|
|
|
this.add_child(this._mainBox);
|
|
|
|
|
2019-10-21 18:44:00 +00:00
|
|
|
this.cancelButton = new St.Button({
|
2020-01-14 15:15:48 +00:00
|
|
|
style_class: 'modal-dialog-button button cancel-button',
|
2020-02-19 17:06:38 +00:00
|
|
|
accessible_name: _('Cancel'),
|
2019-10-21 18:44:00 +00:00
|
|
|
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
|
2020-02-14 16:14:55 +00:00
|
|
|
reactive: this._hasCancelButton,
|
2020-02-19 16:32:22 +00:00
|
|
|
can_focus: this._hasCancelButton,
|
2019-10-17 21:27:27 +00:00
|
|
|
x_align: Clutter.ActorAlign.START,
|
2020-01-14 19:02:24 +00:00
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
2020-01-14 15:15:48 +00:00
|
|
|
child: new St.Icon({ icon_name: 'go-previous-symbolic' }),
|
2019-10-21 18:44:00 +00:00
|
|
|
});
|
2020-02-14 16:14:55 +00:00
|
|
|
if (this._hasCancelButton)
|
|
|
|
this.cancelButton.connect('clicked', () => this.cancel());
|
|
|
|
else
|
|
|
|
this.cancelButton.opacity = 0;
|
2020-01-14 19:02:24 +00:00
|
|
|
this._mainBox.add_child(this.cancelButton);
|
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
this._authList = new AuthList.AuthList();
|
|
|
|
this._authList.set({
|
|
|
|
visible: false,
|
|
|
|
});
|
|
|
|
this._authList.connect('activate', (list, key) => {
|
|
|
|
this._authList.reactive = false;
|
|
|
|
this._authList.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: MESSAGE_FADE_OUT_ANIMATION_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => {
|
|
|
|
this._authList.clear();
|
|
|
|
this._authList.hide();
|
|
|
|
this._userVerifier.selectChoice(this._queryingService, key);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this._mainBox.add_child(this._authList);
|
|
|
|
|
2020-01-14 19:02:24 +00:00
|
|
|
let entryParams = {
|
|
|
|
style_class: 'login-dialog-prompt-entry',
|
|
|
|
can_focus: true,
|
|
|
|
x_expand: true,
|
|
|
|
};
|
2019-10-21 18:44:00 +00:00
|
|
|
|
2020-01-14 19:02:24 +00:00
|
|
|
this._entry = null;
|
|
|
|
|
|
|
|
this._textEntry = new St.Entry(entryParams);
|
|
|
|
ShellEntry.addContextMenu(this._textEntry, { actionMode: Shell.ActionMode.NONE });
|
|
|
|
|
|
|
|
this._passwordEntry = new St.PasswordEntry(entryParams);
|
|
|
|
ShellEntry.addContextMenu(this._passwordEntry, { actionMode: Shell.ActionMode.NONE });
|
|
|
|
|
|
|
|
this._entry = this._passwordEntry;
|
|
|
|
this._mainBox.add_child(this._entry);
|
|
|
|
this._entry.grab_key_focus();
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2021-04-13 14:59:49 +00:00
|
|
|
this._timedLoginIndicator = new St.Bin({
|
|
|
|
style_class: 'login-dialog-timed-login-indicator',
|
|
|
|
scale_x: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.add_child(this._timedLoginIndicator);
|
|
|
|
|
2020-02-06 20:27:20 +00:00
|
|
|
[this._textEntry, this._passwordEntry].forEach(entry => {
|
|
|
|
entry.clutter_text.connect('text-changed', () => {
|
|
|
|
if (!this._userVerifier.hasPendingMessages)
|
|
|
|
this._fadeOutMessage();
|
|
|
|
});
|
|
|
|
|
|
|
|
entry.clutter_text.connect('activate', () => {
|
2020-02-11 13:33:02 +00:00
|
|
|
let shouldSpin = entry === this._passwordEntry;
|
2020-02-06 20:27:20 +00:00
|
|
|
if (entry.reactive)
|
2020-02-11 13:33:02 +00:00
|
|
|
this._activateNext(shouldSpin);
|
2020-02-06 20:27:20 +00:00
|
|
|
});
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2020-01-14 19:02:24 +00:00
|
|
|
|
|
|
|
this._defaultButtonWell = new St.Widget({
|
|
|
|
layout_manager: new Clutter.BinLayout(),
|
|
|
|
x_align: Clutter.ActorAlign.END,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
2020-02-06 20:51:18 +00:00
|
|
|
this._defaultButtonWell.add_constraint(new Clutter.BindConstraint({
|
|
|
|
source: this.cancelButton,
|
2020-04-13 16:55:34 +00:00
|
|
|
coordinate: Clutter.BindCoordinate.WIDTH,
|
2020-02-06 20:51:18 +00:00
|
|
|
}));
|
2020-01-14 19:02:24 +00:00
|
|
|
this._mainBox.add_child(this._defaultButtonWell);
|
|
|
|
|
|
|
|
this._spinner = new Animation.Spinner(DEFAULT_BUTTON_WELL_ICON_SIZE);
|
|
|
|
this._defaultButtonWell.add_child(this._spinner);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2021-04-13 14:59:49 +00:00
|
|
|
showTimedLoginIndicator(time) {
|
|
|
|
let hold = new Batch.Hold();
|
|
|
|
|
|
|
|
this.hideTimedLoginIndicator();
|
|
|
|
|
|
|
|
const startTime = GLib.get_monotonic_time();
|
|
|
|
|
|
|
|
this._timedLoginTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 33,
|
|
|
|
() => {
|
|
|
|
const currentTime = GLib.get_monotonic_time();
|
|
|
|
const elapsedTime = (currentTime - startTime) / GLib.USEC_PER_SEC;
|
|
|
|
this._timedLoginIndicator.scale_x = elapsedTime / time;
|
|
|
|
if (elapsedTime >= time) {
|
|
|
|
this._timedLoginTimeoutId = 0;
|
|
|
|
hold.release();
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GLib.SOURCE_CONTINUE;
|
|
|
|
});
|
|
|
|
|
|
|
|
GLib.Source.set_name_by_id(this._timedLoginTimeoutId, '[gnome-shell] this._timedLoginTimeoutId');
|
|
|
|
|
|
|
|
return hold;
|
|
|
|
}
|
|
|
|
|
|
|
|
hideTimedLoginIndicator() {
|
|
|
|
if (this._timedLoginTimeoutId) {
|
|
|
|
GLib.source_remove(this._timedLoginTimeoutId);
|
|
|
|
this._timedLoginTimeoutId = 0;
|
|
|
|
}
|
|
|
|
this._timedLoginIndicator.scale_x = 0.;
|
|
|
|
}
|
|
|
|
|
2020-02-11 13:33:02 +00:00
|
|
|
_activateNext(shouldSpin) {
|
2021-02-01 12:10:45 +00:00
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFICATION_IN_PROGRESS;
|
2020-02-11 13:27:36 +00:00
|
|
|
this.updateSensitivity(false);
|
2020-02-11 13:33:02 +00:00
|
|
|
|
|
|
|
if (shouldSpin)
|
|
|
|
this.startSpinning();
|
|
|
|
|
2020-02-11 13:27:36 +00:00
|
|
|
if (this._queryingService)
|
|
|
|
this._userVerifier.answerQuery(this._queryingService, this._entry.text);
|
|
|
|
else
|
|
|
|
this._preemptiveAnswer = this._entry.text;
|
|
|
|
|
|
|
|
this.emit('next');
|
|
|
|
}
|
|
|
|
|
2019-12-12 09:32:53 +00:00
|
|
|
_updateEntry(secret) {
|
2020-02-06 20:20:48 +00:00
|
|
|
if (secret && this._entry !== this._passwordEntry) {
|
2020-01-14 19:02:24 +00:00
|
|
|
this._mainBox.replace_child(this._entry, this._passwordEntry);
|
2019-12-12 09:32:53 +00:00
|
|
|
this._entry = this._passwordEntry;
|
2020-02-06 20:20:48 +00:00
|
|
|
} else if (!secret && this._entry !== this._textEntry) {
|
2020-01-14 19:02:24 +00:00
|
|
|
this._mainBox.replace_child(this._entry, this._textEntry);
|
2019-12-12 09:32:53 +00:00
|
|
|
this._entry = this._textEntry;
|
|
|
|
}
|
2020-02-14 19:50:59 +00:00
|
|
|
this._capsLockWarningLabel.visible = secret;
|
2019-12-12 09:32:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onAskQuestion(verifier, serviceName, question, secret) {
|
2013-07-22 15:07:35 +00:00
|
|
|
if (this._queryingService)
|
|
|
|
this.clear();
|
|
|
|
|
|
|
|
this._queryingService = serviceName;
|
2015-04-07 19:53:42 +00:00
|
|
|
if (this._preemptiveAnswer) {
|
|
|
|
this._userVerifier.answerQuery(this._queryingService, this._preemptiveAnswer);
|
|
|
|
this._preemptiveAnswer = null;
|
|
|
|
return;
|
|
|
|
}
|
2019-12-12 09:32:53 +00:00
|
|
|
|
|
|
|
this._updateEntry(secret);
|
2020-02-14 21:14:25 +00:00
|
|
|
|
|
|
|
// Hack: The question string comes directly from PAM, if it's "Password:"
|
|
|
|
// we replace it with our own to allow localization, if it's something
|
|
|
|
// else we remove the last colon and any trailing or leading spaces.
|
|
|
|
if (question === 'Password:' || question === 'Password: ')
|
|
|
|
this.setQuestion(_('Password'));
|
|
|
|
else
|
|
|
|
this.setQuestion(question.replace(/: *$/, '').trim());
|
2013-07-22 15:07:35 +00:00
|
|
|
|
|
|
|
this.updateSensitivity(true);
|
|
|
|
this.emit('prompted');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
_onShowChoiceList(userVerifier, serviceName, promptMessage, choiceList) {
|
|
|
|
if (this._queryingService)
|
|
|
|
this.clear();
|
|
|
|
|
|
|
|
this._queryingService = serviceName;
|
|
|
|
|
|
|
|
if (this._preemptiveAnswer)
|
|
|
|
this._preemptiveAnswer = null;
|
|
|
|
|
|
|
|
this.setChoiceList(promptMessage, choiceList);
|
|
|
|
this.updateSensitivity(true);
|
|
|
|
this.emit('prompted');
|
|
|
|
}
|
|
|
|
|
2020-01-03 16:31:15 +00:00
|
|
|
_onCredentialManagerAuthenticated() {
|
2013-10-10 08:21:47 +00:00
|
|
|
if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
|
|
|
|
this.reset();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-10-10 08:21:47 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onSmartcardStatusChanged() {
|
2013-06-27 12:54:19 +00:00
|
|
|
this.smartcardDetected = this._userVerifier.smartcardDetected;
|
|
|
|
|
|
|
|
// Most of the time we want to reset if the user inserts or removes
|
|
|
|
// a smartcard. Smartcard insertion "preempts" what the user was
|
|
|
|
// doing, and smartcard removal aborts the preemption.
|
|
|
|
// The exceptions are: 1) Don't reset on smartcard insertion if we're already verifying
|
|
|
|
// with a smartcard
|
|
|
|
// 2) Don't reset if we've already succeeded at verification and
|
|
|
|
// the user is getting logged in.
|
|
|
|
if (this._userVerifier.serviceIsDefault(GdmUtil.SMARTCARD_SERVICE_NAME) &&
|
|
|
|
this.verificationStatus == AuthPromptStatus.VERIFYING &&
|
|
|
|
this.smartcardDetected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
|
|
|
|
this.reset();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-06-27 12:54:19 +00:00
|
|
|
|
2021-02-01 18:36:49 +00:00
|
|
|
_onShowMessage(_userVerifier, serviceName, message, type) {
|
|
|
|
this.setMessage(serviceName, message, type);
|
2013-07-29 18:37:10 +00:00
|
|
|
this.emit('prompted');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2021-02-01 18:36:49 +00:00
|
|
|
_onVerificationFailed(userVerifier, serviceName, canRetry) {
|
2021-02-01 18:39:03 +00:00
|
|
|
const wasQueryingService = this._queryingService === serviceName;
|
2021-04-28 14:36:46 +00:00
|
|
|
|
|
|
|
if (wasQueryingService) {
|
|
|
|
this._queryingService = null;
|
|
|
|
this.clear();
|
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2018-05-29 00:00:04 +00:00
|
|
|
this.updateSensitivity(canRetry);
|
2013-07-22 15:07:35 +00:00
|
|
|
this.setActorInDefaultButtonWell(null);
|
2021-04-28 14:38:58 +00:00
|
|
|
|
|
|
|
if (!canRetry)
|
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFICATION_FAILED;
|
2019-10-15 19:34:35 +00:00
|
|
|
|
2021-02-01 18:39:03 +00:00
|
|
|
if (wasQueryingService)
|
|
|
|
Util.wiggle(this._entry);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onVerificationComplete() {
|
2015-08-31 19:21:15 +00:00
|
|
|
this.setActorInDefaultButtonWell(null);
|
2013-07-28 20:24:31 +00:00
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFICATION_SUCCEEDED;
|
2017-06-29 23:16:11 +00:00
|
|
|
this.cancelButton.reactive = false;
|
2020-02-19 16:32:22 +00:00
|
|
|
this.cancelButton.can_focus = false;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onReset() {
|
2013-11-26 03:30:53 +00:00
|
|
|
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
|
|
|
|
this.reset();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setActorInDefaultButtonWell(actor, animate) {
|
2013-07-24 00:37:42 +00:00
|
|
|
if (!this._defaultButtonWellActor &&
|
|
|
|
!actor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let oldActor = this._defaultButtonWellActor;
|
|
|
|
|
|
|
|
if (oldActor)
|
2018-07-20 19:46:19 +00:00
|
|
|
oldActor.remove_all_transitions();
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2015-08-21 13:09:39 +00:00
|
|
|
let wasSpinner;
|
2019-07-16 09:24:13 +00:00
|
|
|
if (oldActor == this._spinner)
|
2015-08-21 13:09:39 +00:00
|
|
|
wasSpinner = true;
|
|
|
|
else
|
|
|
|
wasSpinner = false;
|
|
|
|
|
2013-07-24 00:37:42 +00:00
|
|
|
let isSpinner;
|
2019-07-16 09:24:13 +00:00
|
|
|
if (actor == this._spinner)
|
2013-07-24 00:37:42 +00:00
|
|
|
isSpinner = true;
|
|
|
|
else
|
|
|
|
isSpinner = false;
|
|
|
|
|
|
|
|
if (this._defaultButtonWellActor != actor && oldActor) {
|
|
|
|
if (!animate) {
|
|
|
|
oldActor.opacity = 0;
|
2015-08-21 13:09:39 +00:00
|
|
|
|
|
|
|
if (wasSpinner) {
|
|
|
|
if (this._spinner)
|
|
|
|
this._spinner.stop();
|
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
} else {
|
2018-07-20 19:46:19 +00:00
|
|
|
oldActor.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: DEFAULT_BUTTON_WELL_ANIMATION_TIME,
|
|
|
|
delay: DEFAULT_BUTTON_WELL_ANIMATION_DELAY,
|
|
|
|
mode: Clutter.AnimationMode.LINEAR,
|
|
|
|
onComplete: () => {
|
|
|
|
if (wasSpinner) {
|
|
|
|
if (this._spinner)
|
|
|
|
this._spinner.stop();
|
|
|
|
}
|
2019-08-20 21:43:54 +00:00
|
|
|
},
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2013-07-24 00:37:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor) {
|
|
|
|
if (isSpinner)
|
|
|
|
this._spinner.play();
|
|
|
|
|
2019-08-20 00:51:42 +00:00
|
|
|
if (!animate) {
|
2013-07-24 00:37:42 +00:00
|
|
|
actor.opacity = 255;
|
2019-08-20 00:51:42 +00:00
|
|
|
} else {
|
2018-07-20 19:46:19 +00:00
|
|
|
actor.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: DEFAULT_BUTTON_WELL_ANIMATION_TIME,
|
|
|
|
delay: DEFAULT_BUTTON_WELL_ANIMATION_DELAY,
|
2019-08-20 21:43:54 +00:00
|
|
|
mode: Clutter.AnimationMode.LINEAR,
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2019-08-20 00:51:42 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._defaultButtonWellActor = actor;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
startSpinning() {
|
2019-07-16 09:24:13 +00:00
|
|
|
this.setActorInDefaultButtonWell(this._spinner, true);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
stopSpinning() {
|
2013-07-24 00:37:42 +00:00
|
|
|
this.setActorInDefaultButtonWell(null, false);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
clear() {
|
2013-07-24 00:37:42 +00:00
|
|
|
this._entry.text = '';
|
|
|
|
this.stopSpinning();
|
2017-07-17 20:48:03 +00:00
|
|
|
this._authList.clear();
|
|
|
|
this._authList.hide();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setQuestion(question) {
|
2020-02-06 19:57:53 +00:00
|
|
|
this._entry.hint_text = question;
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
this._authList.hide();
|
2013-07-24 00:37:42 +00:00
|
|
|
this._entry.show();
|
|
|
|
this._entry.grab_key_focus();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
_fadeInChoiceList() {
|
|
|
|
this._authList.set({
|
|
|
|
opacity: 0,
|
|
|
|
visible: true,
|
|
|
|
reactive: false,
|
|
|
|
});
|
|
|
|
this._authList.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: MESSAGE_FADE_OUT_ANIMATION_TIME,
|
|
|
|
transition: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => (this._authList.reactive = true),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setChoiceList(promptMessage, choiceList) {
|
|
|
|
this._authList.clear();
|
|
|
|
this._authList.label.text = promptMessage;
|
|
|
|
for (let key in choiceList) {
|
|
|
|
let text = choiceList[key];
|
|
|
|
this._authList.addItem(key, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._entry.hide();
|
|
|
|
if (this._message.text === '')
|
|
|
|
this._message.hide();
|
|
|
|
this._fadeInChoiceList();
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getAnswer() {
|
2013-08-02 18:10:16 +00:00
|
|
|
let text;
|
|
|
|
|
|
|
|
if (this._preemptiveAnswer) {
|
|
|
|
text = this._preemptiveAnswer;
|
|
|
|
this._preemptiveAnswer = null;
|
|
|
|
} else {
|
|
|
|
text = this._entry.get_text();
|
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
|
|
|
return text;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_fadeOutMessage() {
|
2013-07-24 14:53:48 +00:00
|
|
|
if (this._message.opacity == 0)
|
|
|
|
return;
|
2018-07-20 19:46:19 +00:00
|
|
|
this._message.remove_all_transitions();
|
|
|
|
this._message.ease({
|
|
|
|
opacity: 0,
|
|
|
|
duration: MESSAGE_FADE_OUT_ANIMATION_TIME,
|
2019-08-20 21:43:54 +00:00
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2018-07-20 19:46:19 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 14:53:48 +00:00
|
|
|
|
2021-02-01 18:36:49 +00:00
|
|
|
setMessage(serviceName, message, type) {
|
2013-08-27 14:17:26 +00:00
|
|
|
if (type == GdmUtil.MessageType.ERROR)
|
|
|
|
this._message.add_style_class_name('login-dialog-message-warning');
|
|
|
|
else
|
|
|
|
this._message.remove_style_class_name('login-dialog-message-warning');
|
2013-08-19 16:00:33 +00:00
|
|
|
|
2013-08-27 14:17:26 +00:00
|
|
|
if (type == GdmUtil.MessageType.HINT)
|
|
|
|
this._message.add_style_class_name('login-dialog-message-hint');
|
|
|
|
else
|
|
|
|
this._message.remove_style_class_name('login-dialog-message-hint');
|
2013-08-19 16:00:33 +00:00
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
this._message.show();
|
2013-07-24 00:37:42 +00:00
|
|
|
if (message) {
|
2018-07-20 19:46:19 +00:00
|
|
|
this._message.remove_all_transitions();
|
2013-07-24 00:37:42 +00:00
|
|
|
this._message.text = message;
|
|
|
|
this._message.opacity = 255;
|
|
|
|
} else {
|
|
|
|
this._message.opacity = 0;
|
|
|
|
}
|
2021-02-01 18:44:00 +00:00
|
|
|
|
|
|
|
if (type === GdmUtil.MessageType.ERROR &&
|
2021-02-08 18:34:09 +00:00
|
|
|
this._userVerifier.serviceIsFingerprint(serviceName)) {
|
|
|
|
// TODO: Use Await for wiggle to be over before unfreezing the user verifier queue
|
|
|
|
const wiggleParameters = {
|
|
|
|
duration: 65,
|
|
|
|
wiggleCount: 3,
|
|
|
|
};
|
|
|
|
this._userVerifier.increaseCurrentMessageTimeout(
|
|
|
|
wiggleParameters.duration * (wiggleParameters.wiggleCount + 2));
|
|
|
|
Util.wiggle(this._message, wiggleParameters);
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
updateSensitivity(sensitive) {
|
2020-04-22 15:27:54 +00:00
|
|
|
if (this._entry.reactive === sensitive)
|
|
|
|
return;
|
|
|
|
|
2013-07-24 00:37:42 +00:00
|
|
|
this._entry.reactive = sensitive;
|
2020-04-22 15:27:54 +00:00
|
|
|
|
2021-02-01 11:52:01 +00:00
|
|
|
if (sensitive) {
|
2020-04-22 15:27:54 +00:00
|
|
|
this._entry.grab_key_focus();
|
2021-02-01 11:52:01 +00:00
|
|
|
} else {
|
|
|
|
this.grab_key_focus();
|
|
|
|
|
|
|
|
if (this._entry === this._passwordEntry)
|
|
|
|
this._entry.password_visible = false;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2019-07-16 09:24:13 +00:00
|
|
|
vfunc_hide() {
|
2013-07-24 00:37:42 +00:00
|
|
|
this.setActorInDefaultButtonWell(null, true);
|
2019-07-16 09:24:13 +00:00
|
|
|
super.vfunc_hide();
|
2013-08-19 16:00:33 +00:00
|
|
|
this._message.opacity = 0;
|
2013-07-24 00:37:42 +00:00
|
|
|
|
|
|
|
this.setUser(null);
|
|
|
|
|
|
|
|
this.updateSensitivity(true);
|
|
|
|
this._entry.set_text('');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setUser(user) {
|
2014-10-09 16:05:11 +00:00
|
|
|
let oldChild = this._userWell.get_child();
|
|
|
|
if (oldChild)
|
|
|
|
oldChild.destroy();
|
|
|
|
|
2020-01-17 06:47:34 +00:00
|
|
|
let userWidget = new UserWidget.UserWidget(user, Clutter.Orientation.VERTICAL);
|
|
|
|
this._userWell.set_child(userWidget);
|
2020-02-06 20:30:36 +00:00
|
|
|
|
|
|
|
if (!user)
|
|
|
|
this._updateEntry(false);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
reset() {
|
2013-07-29 12:46:37 +00:00
|
|
|
let oldStatus = this.verificationStatus;
|
2013-07-28 20:24:31 +00:00
|
|
|
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
|
2020-02-14 16:14:55 +00:00
|
|
|
this.cancelButton.reactive = this._hasCancelButton;
|
2020-02-19 16:32:22 +00:00
|
|
|
this.cancelButton.can_focus = this._hasCancelButton;
|
2018-05-28 23:51:00 +00:00
|
|
|
this._preemptiveAnswer = null;
|
2013-07-29 12:46:37 +00:00
|
|
|
|
2015-07-15 19:52:29 +00:00
|
|
|
if (this._userVerifier)
|
2013-07-29 12:46:37 +00:00
|
|
|
this._userVerifier.cancel();
|
|
|
|
|
2013-07-22 15:07:35 +00:00
|
|
|
this._queryingService = null;
|
|
|
|
this.clear();
|
2013-07-24 00:37:42 +00:00
|
|
|
this._message.opacity = 0;
|
|
|
|
this.setUser(null);
|
2020-02-13 21:05:38 +00:00
|
|
|
this._updateEntry(true);
|
2013-07-24 00:37:42 +00:00
|
|
|
this.stopSpinning();
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2013-07-28 20:06:04 +00:00
|
|
|
if (oldStatus == AuthPromptStatus.VERIFICATION_FAILED)
|
|
|
|
this.emit('failed');
|
2021-01-30 03:18:32 +00:00
|
|
|
else if (oldStatus === AuthPromptStatus.VERIFICATION_CANCELLED)
|
|
|
|
this.emit('cancelled');
|
2013-07-28 20:06:04 +00:00
|
|
|
|
2013-06-27 12:54:19 +00:00
|
|
|
let beginRequestType;
|
|
|
|
|
|
|
|
if (this._mode == AuthPromptMode.UNLOCK_ONLY) {
|
|
|
|
// The user is constant at the unlock screen, so it will immediately
|
|
|
|
// respond to the request with the username
|
2021-01-30 03:18:32 +00:00
|
|
|
if (oldStatus === AuthPromptStatus.VERIFICATION_CANCELLED)
|
|
|
|
return;
|
2013-06-27 12:54:19 +00:00
|
|
|
beginRequestType = BeginRequestType.PROVIDE_USERNAME;
|
2020-08-17 21:41:04 +00:00
|
|
|
} else if (this._userVerifier.serviceIsForeground(OVirt.SERVICE_NAME) ||
|
2020-09-21 14:11:41 +00:00
|
|
|
this._userVerifier.serviceIsForeground(Vmware.SERVICE_NAME) ||
|
2014-03-13 17:43:36 +00:00
|
|
|
this._userVerifier.serviceIsForeground(GdmUtil.SMARTCARD_SERVICE_NAME)) {
|
2013-06-27 12:54:19 +00:00
|
|
|
// We don't need to know the username if the user preempted the login screen
|
2013-10-10 08:21:47 +00:00
|
|
|
// with a smartcard or with preauthenticated oVirt credentials
|
2013-06-27 12:54:19 +00:00
|
|
|
beginRequestType = BeginRequestType.DONT_PROVIDE_USERNAME;
|
2021-02-01 12:10:45 +00:00
|
|
|
} else if (oldStatus === AuthPromptStatus.VERIFICATION_IN_PROGRESS) {
|
|
|
|
// We're going back to retry with current user
|
|
|
|
beginRequestType = BeginRequestType.REUSE_USERNAME;
|
2013-06-27 12:54:19 +00:00
|
|
|
} else {
|
|
|
|
// In all other cases, we should get the username up front.
|
|
|
|
beginRequestType = BeginRequestType.PROVIDE_USERNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.emit('reset', beginRequestType);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-24 00:37:42 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
addCharacter(unichar) {
|
2013-07-24 00:37:42 +00:00
|
|
|
if (!this._entry.visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._entry.grab_key_focus();
|
|
|
|
this._entry.clutter_text.insert_unichar(unichar);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
begin(params) {
|
2013-07-22 15:07:35 +00:00
|
|
|
params = Params.parse(params, { userName: null,
|
|
|
|
hold: null });
|
|
|
|
|
|
|
|
this.updateSensitivity(false);
|
|
|
|
|
|
|
|
let hold = params.hold;
|
|
|
|
if (!hold)
|
|
|
|
hold = new Batch.Hold();
|
|
|
|
|
|
|
|
this._userVerifier.begin(params.userName, hold);
|
2013-07-28 20:24:31 +00:00
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFYING;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
finish(onComplete) {
|
2013-07-22 15:07:35 +00:00
|
|
|
if (!this._userVerifier.hasPendingMessages) {
|
2015-08-03 18:07:17 +00:00
|
|
|
this._userVerifier.clear();
|
2013-07-22 15:07:35 +00:00
|
|
|
onComplete();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
let signalId = this._userVerifier.connect('no-more-messages', () => {
|
|
|
|
this._userVerifier.disconnect(signalId);
|
|
|
|
this._userVerifier.clear();
|
|
|
|
onComplete();
|
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-22 15:07:35 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
cancel() {
|
2019-08-20 00:51:42 +00:00
|
|
|
if (this.verificationStatus == AuthPromptStatus.VERIFICATION_SUCCEEDED)
|
2014-10-05 20:27:00 +00:00
|
|
|
return;
|
2019-08-20 00:51:42 +00:00
|
|
|
|
2021-02-01 12:10:45 +00:00
|
|
|
if (this.verificationStatus === AuthPromptStatus.VERIFICATION_IN_PROGRESS) {
|
|
|
|
this._cancelledRetries++;
|
|
|
|
if (this._cancelledRetries > this._userVerifier.allowedFailures)
|
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFICATION_FAILED;
|
|
|
|
} else {
|
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFICATION_CANCELLED;
|
|
|
|
}
|
|
|
|
|
2013-07-22 15:07:35 +00:00
|
|
|
this.reset();
|
2013-07-24 00:37:42 +00:00
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
});
|