OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 6 * @fileoverview |
7 * REST API for host-list management. | 7 * REST API for host-list management. |
8 */ | 8 */ |
9 | 9 |
10 /** @suppress {duplicate} */ | 10 /** @suppress {duplicate} */ |
(...skipping 24 matching lines...) Expand all Loading... | |
35 url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts', | 35 url: remoting.settings.DIRECTORY_API_BASE_URL + '/@me/hosts', |
36 urlParams: { | 36 urlParams: { |
37 hostClientId: hostClientId | 37 hostClientId: hostClientId |
38 }, | 38 }, |
39 jsonContent: newHostDetails, | 39 jsonContent: newHostDetails, |
40 acceptJson: true, | 40 acceptJson: true, |
41 useIdentity: true | 41 useIdentity: true |
42 }).start().then(function(response) { | 42 }).start().then(function(response) { |
43 if (response.status == 200) { | 43 if (response.status == 200) { |
44 var result = response.getJson(); | 44 var result = response.getJson(); |
45 if (result['data']) { | 45 var data = base.getObjectAttr(result, 'data'); |
46 return base.getStringAttr(result['data'], 'authorizationCode', ''); | 46 var authCode = base.getStringAttr(data, 'authorizationCode'); |
John Williams
2015/04/28 20:27:41
Simplified based on the assumption that the auth c
| |
47 } else { | 47 return { authCode: authCode, email: '' }; |
48 return ''; | |
49 } | |
50 } else { | 48 } else { |
51 console.log( | 49 console.log( |
52 'Failed to register the host. Status: ' + response.status + | 50 'Failed to register the host. Status: ' + response.status + |
53 ' response: ' + response.getText()); | 51 ' response: ' + response.getText()); |
54 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); | 52 throw new remoting.Error(remoting.Error.Tag.REGISTRATION_FAILED); |
55 } | 53 } |
56 }); | 54 }); |
57 }; | 55 }; |
58 | 56 |
59 /** @override */ | 57 /** @override */ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 if (opt_ignoreErrors && error.hasTag.apply(error, opt_ignoreErrors)) { | 151 if (opt_ignoreErrors && error.hasTag.apply(error, opt_ignoreErrors)) { |
154 return; | 152 return; |
155 } | 153 } |
156 | 154 |
157 throw error; | 155 throw error; |
158 }; | 156 }; |
159 return result; | 157 return result; |
160 }; | 158 }; |
161 | 159 |
162 })(); | 160 })(); |
OLD | NEW |