Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Polymer element for displaying AD domain joining and AD | 6 * @fileoverview Polymer element for displaying AD domain joining and AD |
| 7 * Authenticate user screens. | 7 * Authenticate user screens. |
| 8 */ | 8 */ |
| 9 // Possible error states of the screen. Must be in the same order as | |
| 10 // ActiveDirectoryErrorState enum values. | |
| 11 /** @const */ var ACTIVE_DIRECTORY_ERROR_STATE = { | |
|
michaelpg
2017/01/18 00:32:30
@enum {number} instead of const
Roman Sorokin (ftl)
2017/01/18 13:56:44
Done.
| |
| 12 NONE : 0, | |
|
michaelpg
2017/01/18 00:32:30
no space before :
Roman Sorokin (ftl)
2017/01/18 13:56:43
Done.
| |
| 13 MACHINE_NAME_INVALID : 1, | |
| 14 MACHINE_NAME_TOO_LONG : 2, | |
| 15 BAD_USERNAME : 3, | |
| 16 BAD_PASSWORD : 4, | |
| 17 }; | |
| 9 | 18 |
| 10 Polymer({ | 19 Polymer({ |
| 11 is: 'offline-ad-login', | 20 is: 'offline-ad-login', |
| 12 | 21 |
| 22 | |
|
michaelpg
2017/01/18 00:32:30
remove blank line
Roman Sorokin (ftl)
2017/01/18 13:56:43
Done.
| |
| 13 properties: { | 23 properties: { |
| 14 /** | 24 /** |
| 15 * Whether the UI disabled. | 25 * Whether the UI disabled. |
| 16 */ | 26 */ |
| 17 disabled: { | 27 disabled: { |
| 18 type: Boolean, | 28 type: Boolean, |
| 19 value: false, | 29 value: false, |
| 20 observer: 'disabledChanged_' | 30 observer: 'disabledChanged_' |
| 21 }, | 31 }, |
| 22 /** | 32 /** |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 33 type: String, | 43 type: String, |
| 34 observer: 'realmChanged_' | 44 observer: 'realmChanged_' |
| 35 }, | 45 }, |
| 36 /** | 46 /** |
| 37 * The user kerberos default realm. Used for autocompletion. | 47 * The user kerberos default realm. Used for autocompletion. |
| 38 */ | 48 */ |
| 39 userRealm: String, | 49 userRealm: String, |
| 40 /** | 50 /** |
| 41 * Welcome message on top of the UI. | 51 * Welcome message on top of the UI. |
| 42 */ | 52 */ |
| 43 adWelcomeMessage: String | 53 adWelcomeMessage: String, |
| 54 /** | |
| 55 * Error message for the machine name input. | |
| 56 */ | |
| 57 machineNameError: String, | |
| 44 }, | 58 }, |
| 45 | 59 |
| 46 /** @private */ | 60 /** @private */ |
| 47 realmChanged_: function() { | 61 realmChanged_: function() { |
| 48 this.adWelcomeMessage = | 62 this.adWelcomeMessage = |
| 49 loadTimeData.getStringF('adAuthWelcomeMessage', this.realm); | 63 loadTimeData.getStringF('adAuthWelcomeMessage', this.realm); |
| 50 }, | 64 }, |
| 51 | 65 |
| 52 /** @private */ | 66 /** @private */ |
| 53 disabledChanged_: function() { | 67 disabledChanged_: function() { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 66 }, | 80 }, |
| 67 | 81 |
| 68 /** | 82 /** |
| 69 * @param {string|undefined} user | 83 * @param {string|undefined} user |
| 70 * @param {string|undefined} machineName | 84 * @param {string|undefined} machineName |
| 71 */ | 85 */ |
| 72 setUser: function(user, machineName) { | 86 setUser: function(user, machineName) { |
| 73 this.$.userInput.value = user || ''; | 87 this.$.userInput.value = user || ''; |
| 74 this.$.machineNameInput.value = machineName || ''; | 88 this.$.machineNameInput.value = machineName || ''; |
| 75 this.$.passwordInput.value = ''; | 89 this.$.passwordInput.value = ''; |
| 76 this.$.passwordInput.isInvalid = !!user; | |
| 77 this.focus(); | 90 this.focus(); |
| 78 }, | 91 }, |
| 79 | 92 |
| 93 setInvalid: function(value) { | |
|
michaelpg
2017/01/18 00:32:30
how does this get "cleared" after a successful att
michaelpg
2017/01/18 00:32:30
annotate
Roman Sorokin (ftl)
2017/01/18 13:56:43
Done.
Roman Sorokin (ftl)
2017/01/18 13:56:44
Good point! Added it to |showStep|
| |
| 94 this.$.machineNameInput.isInvalid = false; | |
| 95 this.$.userInput.isInvalid = false; | |
| 96 this.$.passwordInput.isInvalid = false; | |
| 97 switch (value) { | |
| 98 case ACTIVE_DIRECTORY_ERROR_STATE.NONE: | |
| 99 break; | |
| 100 case ACTIVE_DIRECTORY_ERROR_STATE.MACHINE_NAME_INVALID: | |
| 101 this.machineNameError = | |
| 102 loadTimeData.getString('adJoinErrorMachineNameInvalid'); | |
| 103 this.$.machineNameInput.isInvalid = true; | |
| 104 break; | |
| 105 case ACTIVE_DIRECTORY_ERROR_STATE.MACHINE_NAME_TOO_LONG: | |
| 106 this.machineNameError = | |
| 107 loadTimeData.getString('adJoinErrorMachineNameTooLong'); | |
| 108 this.$.machineNameInput.isInvalid = true; | |
| 109 break; | |
| 110 case ACTIVE_DIRECTORY_ERROR_STATE.BAD_USERNAME: | |
| 111 this.$.userInput.isInvalid = true; | |
| 112 break; | |
| 113 case ACTIVE_DIRECTORY_ERROR_STATE.BAD_PASSWORD: | |
| 114 this.$.passwordInput.isInvalid = true; | |
| 115 break; | |
| 116 } | |
| 117 }, | |
| 118 | |
| 80 /** @private */ | 119 /** @private */ |
| 81 onSubmit_: function() { | 120 onSubmit_: function() { |
| 82 if (this.showMachineInput && !this.$.machineNameInput.checkValidity()) | 121 if (this.showMachineInput && !this.$.machineNameInput.checkValidity()) |
| 83 return; | 122 return; |
| 84 if (!this.$.passwordInput.checkValidity()) | 123 if (!this.$.passwordInput.checkValidity()) |
| 85 return; | 124 return; |
| 86 var user = /** @type {string} */ (this.$.userInput.value); | 125 var user = /** @type {string} */ (this.$.userInput.value); |
| 87 if (!user.includes('@') && this.userRealm) | 126 if (!user.includes('@') && this.userRealm) |
| 88 user += this.userRealm; | 127 user += this.userRealm; |
| 89 var msg = { | 128 var msg = { |
| 90 'machinename': this.$.machineNameInput.value, | 129 'machinename': this.$.machineNameInput.value, |
| 91 'username': user, | 130 'username': user, |
| 92 'password': this.$.passwordInput.value | 131 'password': this.$.passwordInput.value |
| 93 }; | 132 }; |
| 94 this.$.passwordInput.value = ''; | 133 this.$.passwordInput.value = ''; |
| 95 this.fire('authCompleted', msg); | 134 this.fire('authCompleted', msg); |
| 96 }, | 135 }, |
| 97 }); | 136 }); |
| OLD | NEW |