|
27 | 27 | <p> |
28 | 28 | To activate your account, please log in. |
29 | 29 | </p> |
30 | | - <button |
31 | | - id="connect-orcid-button" |
32 | | - class="button orcidBtn" |
33 | | - v-bind:class="{'is-loading': loginProcessing}" |
34 | | - v-bind:disabled="loginProcessing" |
35 | | - v-on:click="orcidLogin" |
36 | | - > |
37 | | - SIGN IN with ORCID |
38 | | - <img |
39 | | - id="orcid-id-icon" |
40 | | - src="https://orcid.org/sites/default/files/images/orcid_24x24.png" |
41 | | - width="24" |
42 | | - height="24" |
43 | | - class="is-pulled-right" |
44 | | - alt="ORCID iD icon" |
| 30 | + <div> |
| 31 | + <button |
| 32 | + v-if="alternateAuthenticationEnabled()" |
| 33 | + id="connect-github-button" |
| 34 | + class="button githubBtn" |
| 35 | + v-bind:class="{'is-loading': loginGithubProcessing}" |
| 36 | + v-bind:disabled="loginGithubProcessing" |
| 37 | + v-on:click="githubLogin" |
| 38 | + > |
| 39 | + SIGN IN with GitHub |
| 40 | + </button> |
| 41 | + </div> |
| 42 | + <div> |
| 43 | + <button |
| 44 | + id="connect-orcid-button" |
| 45 | + class="button orcidBtn" |
| 46 | + v-bind:class="{'is-loading': loginProcessing}" |
| 47 | + v-bind:disabled="loginProcessing" |
| 48 | + v-on:click="orcidLogin" |
45 | 49 | > |
46 | | - </button> |
| 50 | + SIGN IN with ORCID |
| 51 | + <img |
| 52 | + id="orcid-id-icon" |
| 53 | + src="https://orcid.org/sites/default/files/images/orcid_24x24.png" |
| 54 | + width="24" |
| 55 | + height="24" |
| 56 | + class="is-pulled-right" |
| 57 | + alt="ORCID iD icon" |
| 58 | + > |
| 59 | + </button> |
| 60 | + </div> |
47 | 61 | <p class="is-size-7 has-text-left"> |
48 | 62 | To acknowledge that you have used your iD and that it has been authenticated, we display |
49 | 63 | the ORCID iD icon |
|
79 | 93 | }) |
80 | 94 | export default class AccountSignUp extends Vue { |
81 | 95 | public loginProcessing: boolean = false; |
| 96 | + public loginGithubProcessing: boolean = false; |
82 | 97 | public accountTokenCookieName: string = Vue.prototype.$cookieNames.accountToken; |
83 | 98 | public isLoginServerErrorModalActive: boolean = false; |
84 | 99 | @Prop() |
|
110 | 125 | // Start login process |
111 | 126 | window.location.href = process.env.VUE_APP_BI_API_ROOT+'/sso/start'; |
112 | 127 | } |
| 128 | +
|
| 129 | + async githubLogin() { |
| 130 | + // Check the server can be contacted |
| 131 | + this.loginGithubProcessing = true; |
| 132 | + try { |
| 133 | + await ServerManagementService.checkHealth(); |
| 134 | + } catch (error) { |
| 135 | + this.isLoginServerErrorModalActive = true; |
| 136 | + this.loginGithubProcessing = false; |
| 137 | + return; |
| 138 | + } |
| 139 | +
|
| 140 | + // Set the cookie to pass back their account token. Timeout is an hour |
| 141 | + Vue.$cookies.set(this.accountTokenCookieName, this.accountToken, 60*60); |
| 142 | +
|
| 143 | + // Start login process |
| 144 | + window.location.href = process.env.VUE_APP_BI_API_ROOT+'/sso/start/github'; |
| 145 | + } |
| 146 | +
|
| 147 | + alternateAuthenticationEnabled() { |
| 148 | + return process.env.VUE_APP_ALTERNATE_AUTHENTICATION_ENABLED === 'true'; |
| 149 | + } |
113 | 150 | } |
114 | 151 | </script> |
115 | 152 |
|
|
0 commit comments