diff --git a/src/backend/api.js b/src/backend/api.js
index c51845ed..8c5bc704 100644
--- a/src/backend/api.js
+++ b/src/backend/api.js
@@ -53,6 +53,10 @@ export const checkVerified = async () => {
const { data } = await axios.get('/auth/login')
return data.verified
}
+export const getCurrentPolicies = async () => {
+ const { data } = await axios.get('/v1/policies/current')
+ return data.items
+}
/* Wiki endpoints */
export const countWikis = async () => (await axios.get('/wiki/count')).data.data // TODO This doesn't seem to exist and not used?
diff --git a/src/components/Cards/CreateAccount.vue b/src/components/Cards/CreateAccount.vue
index 3e19ab3b..b2b2f32b 100644
--- a/src/components/Cards/CreateAccount.vue
+++ b/src/components/Cards/CreateAccount.vue
@@ -39,31 +39,55 @@
:disabled="inFlight"
:error-messages="error['inputPasswordConfirmation']"
/>
-
This site is protected by reCAPTCHA. Wikibase Cloud Privacy Policy and Google @@ -106,15 +130,47 @@ export default { hasError: false, error: [], inFlight: false, + policies: [], + loadingPolicies: true, } }, - created () { + async created () { this.checkCurrentLogin() + + try { + this.policies = (await this.$api.getCurrentPolicies()) + .map( + policy => ({ + ...policy, + name: policy.metadata.type.replaceAll('-', ' '), + url: `/${policy.metadata.type}/${policy.metadata.active_from}`, + }), + ) + } catch (err) { + console.error(err) + // The policies array remains empty, so we fall back to the default terms of use + // message. After sign up, the user will be prompted to accept any policies they + // missed. (See T401223) + } finally { + this.loadingPolicies = false + } }, updated () { this.checkCurrentLogin() }, methods: { + getPolicySeparator (idx) { + const count = this.policies.length + if (idx === 0) { + return ' ' + } else if (count === 2) { + return ' and the ' + } else if (idx === count - 1) { + return ', and the ' + } else { + return ', the ' + } + }, resetErrorState () { this.hasError = false this.error = [] @@ -140,9 +196,14 @@ export default { // Check for the terms if (this.terms === false) { this.hasError = true - this.error.terms = 'You must accept the Terms of Service.' + this.error.terms = 'You must accept the policies.' } + const acceptedPolicies = Array.from( + this.policies, + policy => policy.metadata.policy_id, + ) + // Check for matching confirmed password if (this.password !== this.passwordConfirmation) { this.hasError = true @@ -166,6 +227,7 @@ export default { email: this.email, password: this.password, recaptcha: token, + accepted_policies: acceptedPolicies, }) .then(success => this.createSuccessful(success)) .catch(errors => {