|
14 | 14 | Open Authentication |
15 | 15 | </v-btn> |
16 | 16 | </v-alert> |
17 | | - <v-alert :value="oAuthCode === '' && oAuthUrl !== ''" type="info"> |
18 | | - CloudControlCenter has detected an authentication request. Click here to open the authentication URL: |
| 17 | + <v-alert :value="googleAuth && !completedAuth" type="info"> |
| 18 | + CloudControlCenter has detected a google authentication request. After you've clicked the following |
| 19 | + button and authenticated in, copy the Google authorization code you'll get into the text input below. |
19 | 20 | <v-btn v-on:click="doOAuth"> |
20 | 21 | Open Authentication |
21 | 22 | </v-btn> |
| 23 | + <v-form v-on:submit="sendGoogleAuth"> |
| 24 | + <v-text-field autofocus v-model="googleAuthCode"></v-text-field> |
| 25 | + <v-btn type="submit">Send code</v-btn> |
| 26 | + </v-form> |
22 | 27 | </v-alert> |
23 | 28 | <v-alert :value="requiresMFA" type="info"> |
24 | 29 | CloudControlCenter has detected an MFA code request. Enter the current code of your authenticator: |
@@ -83,8 +88,12 @@ export default class Progress extends Vue { |
83 | 88 | public currentError: string = ''; |
84 | 89 |
|
85 | 90 | public requiresMFA: boolean = false; |
| 91 | + public googleAuth: boolean = false; |
| 92 | + public googleAuthCode: string = ''; |
86 | 93 | public mfaCode: string = ''; |
87 | 94 |
|
| 95 | + public completedAuth: boolean = false; |
| 96 | +
|
88 | 97 | public mounted() { |
89 | 98 | axios.default.get('/api/steps') |
90 | 99 | .then( |
@@ -151,13 +160,12 @@ export default class Progress extends Vue { |
151 | 160 | } |
152 | 161 | } |
153 | 162 |
|
154 | | - const googleOauthRegexp = new RegExp( |
155 | | - 'Your browser has been opened to visit:\n\n\s+(.+)$' |
156 | | - ); |
| 163 | + const googleOauthRegexp = new RegExp('Go to the following link in your browser:\r<br/>\r<br/> +(.+)') |
157 | 164 | if (googleOauthRegexp.test(output)) { |
158 | 165 | const matches = googleOauthRegexp.exec(output); |
159 | 166 | if (matches) { |
160 | 167 | this.oAuthUrl = matches[1]; |
| 168 | + this.googleAuth = true; |
161 | 169 | } |
162 | 170 | } |
163 | 171 | // MFA feature. Check for a regexp request, but also check if the MFA was already entered. |
@@ -193,6 +201,29 @@ export default class Progress extends Vue { |
193 | 201 | }); |
194 | 202 |
|
195 | 203 | } |
| 204 | +
|
| 205 | + public sendGoogleAuth(event: Event) { |
| 206 | + event.preventDefault(); |
| 207 | + axios.default.post('/api/googleAuth', { |
| 208 | + code: this.googleAuthCode, |
| 209 | + }) |
| 210 | + .then(() => { |
| 211 | + this.googleAuth = false; |
| 212 | + this.googleAuthCode = ''; |
| 213 | + this.currentError = ''; |
| 214 | + this.completedAuth = true; |
| 215 | + }) |
| 216 | + .catch((error) => { |
| 217 | + this.currentError = 'Can not set Google Auth code:'; |
| 218 | + if (error.response) { |
| 219 | + this.currentError = `${this.currentError} ([${error.response.status}] ${error.response.data})`; |
| 220 | + } else if (error.message) { |
| 221 | + this.currentError = `${this.currentError} (${error.message})`; |
| 222 | + } |
| 223 | + }); |
| 224 | +
|
| 225 | + } |
| 226 | +
|
196 | 227 | } |
197 | 228 | </script> |
198 | 229 |
|
|
0 commit comments