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.1
18
import Ubuntu.Components.Popups 0.1
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
32
Component.onCompleted: {
33
if ( systemAuthentication.requireAuthentication() && !noAuthentication) {
39
Displays the login dialog
40
and fires success or failure depending
43
function displayLoginDialog() {
44
var authentication_dialog =
45
PopupUtils.open( Qt.resolvedUrl( "AuthenticationDialog.qml" ),
46
authenticationService );
48
var verify_password = function( password ) {
49
if ( systemAuthentication.validatePasswordToken( password ) ) {
51
PopupUtils.close( authentication_dialog );
54
var dialog_options = {
55
title : i18n.tr( "Authentication failed" )
58
PopupUtils.open( Qt.resolvedUrl( "NotifyDialog.qml" ),
59
authenticationService,
64
authentication_dialog.passwordEntered.connect( verify_password );
65
authentication_dialog.dialogCanceled.connect( denied );
69
id: systemAuthentication
70
serviceName: "terminal"