2
* Copyright (C) 2014 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
import Ubuntu.Components 1.3
18
import Ubuntu.Components.Popups 1.3
19
import com.ubuntu.PamAuthentication 0.1
22
A simple service for authentication.
23
Displays login dialog and fires signals
24
on access approval or denial.
27
id: authenticationService
29
property var __authDialog
30
readonly property bool isDialogVisible: __authDialog != null
35
Component.onCompleted: {
36
if ( systemAuthentication.requireAuthentication() && !noAuthentication) {
42
Displays the login dialog
43
and fires success or failure depending
46
function displayLoginDialog() {
47
var authentication_dialog =
48
PopupUtils.open( Qt.resolvedUrl( "AuthenticationDialog.qml" ),
49
authenticationService );
51
var verify_password = function( password ) {
52
if ( systemAuthentication.validatePasswordToken( password ) ) {
54
PopupUtils.close( authentication_dialog );
57
var dialog_options = {
58
title : i18n.tr( "Authentication failed" )
61
PopupUtils.open( Qt.resolvedUrl( "NotifyDialog.qml" ),
62
authenticationService,
67
authentication_dialog.passwordEntered.connect( verify_password );
68
authentication_dialog.dialogCanceled.connect( denied );
70
__authDialog = authentication_dialog
74
id: systemAuthentication
75
serviceName: "terminal"