| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Polymer element for displaying AD domain joining and AD |
| 7 * Authenticate user screens. |
| 8 */ |
| 9 |
| 10 Polymer({ |
| 11 is: 'offline-ad-login', |
| 12 |
| 13 properties: { |
| 14 /** |
| 15 * Whether the UI disabled. |
| 16 */ |
| 17 disabled: { |
| 18 type: Boolean, |
| 19 value: false, |
| 20 observer: 'disabledChanged_' |
| 21 }, |
| 22 /** |
| 23 * Whether to show machine name input field. |
| 24 */ |
| 25 showMachineInput: { |
| 26 type: Boolean, |
| 27 value: false |
| 28 }, |
| 29 /** |
| 30 * The kerberos realm (AD Domain), the machine is part of. |
| 31 */ |
| 32 realm: { |
| 33 type: String, |
| 34 observer: 'realmChanged_' |
| 35 }, |
| 36 /** |
| 37 * The user kerberos default realm. Used for autocompletion. |
| 38 */ |
| 39 userRealm: String, |
| 40 /** |
| 41 * Welcome message on top of the UI. |
| 42 */ |
| 43 adWelcomeMessage: String |
| 44 }, |
| 45 |
| 46 /** @private */ |
| 47 realmChanged_: function() { |
| 48 this.adWelcomeMessage = |
| 49 loadTimeData.getStringF('AdAuthWelcomeMessage', this.realm); |
| 50 }, |
| 51 |
| 52 /** @private */ |
| 53 disabledChanged_: function() { |
| 54 this.$.gaiaCard.classList.toggle('disabled', this.disabled); |
| 55 }, |
| 56 |
| 57 focus: function() { |
| 58 if (this.showMachineInput && /** @type {string} */ ( |
| 59 this.$.machineNameInput.value) == '') { |
| 60 this.$.machineNameInput.focus(); |
| 61 } else if (/** @type {string} */ (this.$.userInput.value) == '') { |
| 62 this.$.userInput.focus(); |
| 63 } else { |
| 64 this.$.passwordInput.focus(); |
| 65 } |
| 66 }, |
| 67 |
| 68 /** |
| 69 * @param {string|undefined} user |
| 70 * @param {string|undefined} machineName |
| 71 */ |
| 72 setUser: function(user, machineName) { |
| 73 this.$.userInput.value = user || ''; |
| 74 this.$.machineNameInput.value = machineName || ''; |
| 75 this.$.passwordInput.value = ''; |
| 76 this.$.passwordInput.isInvalid = !!user; |
| 77 this.focus(); |
| 78 }, |
| 79 |
| 80 /** @private */ |
| 81 onSubmit_: function() { |
| 82 if (this.showMachineInput && !this.$.machineNameInput.checkValidity()) |
| 83 return; |
| 84 if (!this.$.passwordInput.checkValidity()) |
| 85 return; |
| 86 var user = /** @type {string} */ (this.$.userInput.value); |
| 87 if (!user.includes('@') && this.userRealm) |
| 88 user += this.userRealm; |
| 89 var msg = { |
| 90 'machinename': this.$.machineNameInput.value, |
| 91 'username': user, |
| 92 'password': this.$.passwordInput.value |
| 93 }; |
| 94 this.$.passwordInput.value = ''; |
| 95 this.fire('authCompleted', msg); |
| 96 }, |
| 97 }); |
| OLD | NEW |