diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index 771b3b27502b563a1c5571cb171ad79c9afc36b8..738406082d756150c6c5cea251f75160480f4517 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -5,17 +5,23 @@ const registration = { registering: false }), created () { - if (!this.$store.state.config.registrationOpen || !!this.$store.state.users.currentUser) { + if ((!this.$store.state.config.registrationOpen && !this.token) || !!this.$store.state.users.currentUser) { this.$router.push('/main/all') } + // Seems like this doesn't work at first page open for some reason + if (this.$store.state.config.registrationOpen && this.token) { + this.$router.push('/registration') + } }, computed: { - termsofservice () { return this.$store.state.config.tos } + termsofservice () { return this.$store.state.config.tos }, + token () { return this.$route.params.token } }, methods: { submit () { this.registering = true this.user.nickname = this.user.username + this.user.token = this.token this.$store.state.api.backendInteractor.register(this.user).then( (response) => { if (response.ok) { diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue index 00f665af38ed9b24e8df96af78e157a78e0c005d..087cab6bf9823f871c6a9895b7acb59df059c4a3 100644 --- a/src/components/registration/registration.vue +++ b/src/components/registration/registration.vue @@ -38,6 +38,10 @@ <input :disabled="registering" v-model='user.captcha' placeholder='Enter captcha' type='test' class='form-control' id='captcha'> </div> --> + <div class='form-group' v-if='token' > + <label for='token'>{{$t('registration.token')}}</label> + <input disabled='true' v-model='token' class='form-control' id='token' type='text'> + </div> <div class='form-group'> <button :disabled="registering" type='submit' class='btn btn-default'>{{$t('general.submit')}}</button> </div> diff --git a/src/i18n/messages.js b/src/i18n/messages.js index e9d6e17689c6ea462d26c88a4991ab7da8cfc126..003df68cd6c842a52434752d239ba78449f85e1f 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -354,7 +354,8 @@ const en = { fullname: 'Display name', email: 'Email', bio: 'Bio', - password_confirm: 'Password confirmation' + password_confirm: 'Password confirmation', + token: 'Invite token' }, post_status: { posting: 'Posting', @@ -1643,7 +1644,8 @@ const ru = { fullname: 'Отображаемое имÑ', email: 'Email', bio: 'ОпиÑание', - password_confirm: 'Подтверждение паролÑ' + password_confirm: 'Подтверждение паролÑ', + token: 'Код приглашениÑ' }, post_status: { posting: 'ОтправлÑетÑÑ', diff --git a/src/main.js b/src/main.js index bacd7f6d651de27489bd7f53bee8fd8495655ae9..883e1a31705c8a80e16a3d3329b8cc84e12a90f6 100644 --- a/src/main.js +++ b/src/main.js @@ -119,6 +119,7 @@ window.fetch('/static/config.json') { name: 'mentions', path: '/:username/mentions', component: Mentions }, { name: 'settings', path: '/settings', component: Settings }, { name: 'registration', path: '/registration', component: Registration }, + { name: 'registration', path: '/registration/:token', component: Registration }, { name: 'friend-requests', path: '/friend-requests', component: FollowRequests }, { name: 'user-settings', path: '/user-settings', component: UserSettings } ] diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index adf598b748ccb92091d4b6ddef468808e09ef5e0..13cc47960d2a4b7eeda7ab2ca2041a1c84095fbe 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -159,6 +159,7 @@ const updateProfile = ({credentials, params}) => { // bio // homepage // location +// token const register = (params) => { const form = new FormData()