From 7efa86b23246dee0706fd2c8e0fce4bb264cd6d5 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Sun, 7 Nov 2021 21:57:22 +0100 Subject: [PATCH] Set up paths & namespace to match versioned routes --- .../Auth/ForgotPasswordController.php | 2 +- .../Controllers/Auth/PasswordController.php | 4 ++-- .../Controllers/Auth/RegisterController.php | 4 ++-- .../Auth/ResetPasswordController.php | 2 +- .../v1/Controllers/Auth/UserController.php | 6 +++--- app/Api/v1/Controllers/GroupController.php | 11 +++++----- app/Api/v1/Controllers/IconController.php | 3 ++- app/Api/v1/Controllers/QrCodeController.php | 5 +++-- app/Api/v1/Controllers/SettingController.php | 6 +++--- .../v1/Controllers/TwoFAccountController.php | 21 ++++++++++--------- app/Api/v1/Requests/GroupAssignRequest.php | 2 +- app/Api/v1/Requests/GroupStoreRequest.php | 2 +- app/Api/v1/Requests/QrCodeDecodeRequest.php | 2 +- app/Api/v1/Requests/SettingStoreRequest.php | 2 +- app/Api/v1/Requests/SettingUpdateRequest.php | 2 +- .../v1/Requests/TwoFAccountBatchRequest.php | 2 +- .../v1/Requests/TwoFAccountDynamicRequest.php | 2 +- .../v1/Requests/TwoFAccountReorderRequest.php | 2 +- .../v1/Requests/TwoFAccountStoreRequest.php | 2 +- .../v1/Requests/TwoFAccountUpdateRequest.php | 2 +- app/Api/v1/Requests/TwoFAccountUriRequest.php | 2 +- app/Api/v1/Requests/UserPatchPwdRequest.php | 2 +- app/Api/v1/Requests/UserStoreRequest.php | 2 +- app/Api/v1/Requests/UserUpdateRequest.php | 2 +- app/Api/v1/Resources/GroupResource.php | 2 +- .../v1/Resources/TwoFAccountCollection.php | 4 ++-- .../v1/Resources/TwoFAccountReadResource.php | 2 +- .../v1/Resources/TwoFAccountStoreResource.php | 2 +- app/Api/v1/Resources/UserResource.php | 2 +- app/Providers/RouteServiceProvider.php | 4 ++-- resources/js/components/OtpDisplayer.vue | 8 +++---- resources/js/views/Accounts.vue | 14 ++++++------- resources/js/views/Groups.vue | 4 ++-- resources/js/views/Start.vue | 4 ++-- resources/js/views/auth/Login.vue | 2 +- resources/js/views/auth/Register.vue | 2 +- resources/js/views/auth/password/Request.vue | 2 +- resources/js/views/auth/password/Reset.vue | 2 +- resources/js/views/groups/Create.vue | 2 +- resources/js/views/groups/Edit.vue | 2 +- resources/js/views/settings/Account.vue | 6 +++--- resources/js/views/settings/OAuth.vue | 4 ++-- resources/js/views/settings/Options.vue | 8 +++---- .../js/views/settings/PATokens/Create.vue | 2 +- resources/js/views/twofaccounts/Create.vue | 12 +++++------ resources/js/views/twofaccounts/Edit.vue | 8 +++---- resources/js/views/twofaccounts/QRcode.vue | 2 +- 47 files changed, 98 insertions(+), 94 deletions(-) diff --git a/app/Api/v1/Controllers/Auth/ForgotPasswordController.php b/app/Api/v1/Controllers/Auth/ForgotPasswordController.php index a6bc2d7d..bd98769f 100644 --- a/app/Api/v1/Controllers/Auth/ForgotPasswordController.php +++ b/app/Api/v1/Controllers/Auth/ForgotPasswordController.php @@ -1,6 +1,6 @@ mapWebRoutes(); - $this->mapApiVersionOneRoutes(); // $this->mapApiVersionTwoRoutes(); + + $this->mapWebRoutes(); } /** diff --git a/resources/js/components/OtpDisplayer.vue b/resources/js/components/OtpDisplayer.vue index fc87ac1c..aaffd119 100644 --- a/resources/js/components/OtpDisplayer.vue +++ b/resources/js/components/OtpDisplayer.vue @@ -94,7 +94,7 @@ if( id ) { this.internal_id = id - const { data } = await this.axios.get('api/twofaccounts/' + this.internal_id) + const { data } = await this.axios.get('api/v1/twofaccounts/' + this.internal_id) this.internal_service = data.service this.internal_account = data.account @@ -132,17 +132,17 @@ getOtp: async function() { if(this.internal_id) { - const { data } = await this.axios.get('/api/twofaccounts/' + this.internal_id + '/otp') + const { data } = await this.axios.get('/api/v1/twofaccounts/' + this.internal_id + '/otp') return data } else if(this.internal_uri) { - const { data } = await this.axios.post('/api/twofaccounts/otp', { + const { data } = await this.axios.post('/api/v1/twofaccounts/otp', { uri: this.internal_uri }) return data } else { - const { data } = await this.axios.post('/api/twofaccounts/otp', { + const { data } = await this.axios.post('/api/v1/twofaccounts/otp', { service : this.internal_service, account : this.internal_account, icon : this.internal_icon, diff --git a/resources/js/views/Accounts.vue b/resources/js/views/Accounts.vue index dc1d3c29..f07adfac 100644 --- a/resources/js/views/Accounts.vue +++ b/resources/js/views/Accounts.vue @@ -347,7 +347,7 @@ let accounts = [] this.selectedAccounts = [] - this.axios.get('api/twofaccounts').then(response => { + this.axios.get('api/v1/twofaccounts').then(response => { response.data.forEach((data) => { accounts.push(data) }) @@ -393,7 +393,7 @@ */ saveOrder() { this.drag = false - this.axios.post('/api/twofaccounts/reorder', {orderedIds: this.accounts.map(a => a.id)}) + this.axios.post('/api/v1/twofaccounts/reorder', {orderedIds: this.accounts.map(a => a.id)}) }, /** @@ -406,7 +406,7 @@ this.selectedAccounts.forEach(id => ids.push(id)) // Backend will delete all accounts at the same time - await this.axios.delete('/api/twofaccounts?ids=' + ids.join()) + await this.axios.delete('/api/v1/twofaccounts?ids=' + ids.join()) // we fetch the accounts again to prevent the js collection being // desynchronize from the backend php collection @@ -425,9 +425,9 @@ // Backend will associate all accounts with the selected group in the same move // or withdraw the accounts if destination is 'no group' (id = 0) if(this.moveAccountsTo === 0) { - await this.axios.patch('/api/twofaccounts/withdraw?ids=' + accountsIds.join() ) + await this.axios.patch('/api/v1/twofaccounts/withdraw?ids=' + accountsIds.join() ) } - else await this.axios.post('/api/groups/' + this.moveAccountsTo + '/assign', {ids: accountsIds} ) + else await this.axios.post('/api/v1/groups/' + this.moveAccountsTo + '/assign', {ids: accountsIds} ) // we fetch the accounts again to prevent the js collection being // desynchronize from the backend php collection @@ -443,7 +443,7 @@ fetchGroups() { let groups = [] - this.axios.get('api/groups').then(response => { + this.axios.get('api/v1/groups').then(response => { response.data.forEach((data) => { groups.push(data) }) @@ -466,7 +466,7 @@ // In db saving if the user set 2FAuth to memorize the active group if( this.$root.appSettings.rememberActiveGroup ) { - this.form.put('/api/settings/activeGroup', {returnError: true}) + this.form.put('/api/v1/settings/activeGroup', {returnError: true}) .then(response => { // everything's fine }) diff --git a/resources/js/views/Groups.vue b/resources/js/views/Groups.vue index 311c578a..a571384c 100644 --- a/resources/js/views/Groups.vue +++ b/resources/js/views/Groups.vue @@ -79,7 +79,7 @@ this.isFetching = true - await this.axios.get('api/groups').then(response => { + await this.axios.get('api/v1/groups').then(response => { const groups = [] response.data.forEach((data) => { @@ -101,7 +101,7 @@ */ deleteGroup(id) { if(confirm(this.$t('groups.confirm.delete'))) { - this.axios.delete('/api/groups/' + id) + this.axios.delete('/api/v1/groups/' + id) // Remove the deleted group from the collection this.groups = this.groups.filter(a => a.id !== id) diff --git a/resources/js/views/Start.vue b/resources/js/views/Start.vue index dee1fd02..e92a9fe2 100644 --- a/resources/js/views/Start.vue +++ b/resources/js/views/Start.vue @@ -79,7 +79,7 @@ mounted() { - this.axios.get('api/twofaccounts/count').then(response => { + this.axios.get('api/v1/twofaccounts/count').then(response => { this.accountCount = response.data.count }) }, @@ -105,7 +105,7 @@ imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]); imgdata.append('inputFormat', 'fileUpload'); - const { data } = await this.form.upload('/api/qrcode/decode', imgdata) + const { data } = await this.form.upload('/api/v1/qrcode/decode', imgdata) this.$router.push({ name: 'createAccount', params: { decodedUri: data.data } }); }, diff --git a/resources/js/views/auth/Login.vue b/resources/js/views/auth/Login.vue index ae34e006..085d766c 100644 --- a/resources/js/views/auth/Login.vue +++ b/resources/js/views/auth/Login.vue @@ -61,7 +61,7 @@ // } next(async vm => { - const { data } = await vm.axios.get('api/user/name') + const { data } = await vm.axios.get('api/v1/user/name') if( data.name ) { vm.username = data.name diff --git a/resources/js/views/auth/Register.vue b/resources/js/views/auth/Register.vue index 90d52561..0c80ac7e 100644 --- a/resources/js/views/auth/Register.vue +++ b/resources/js/views/auth/Register.vue @@ -31,7 +31,7 @@ async handleSubmit(e) { e.preventDefault() - this.form.post('/api/user', {returnError: true}) + this.form.post('/api/v1/user', {returnError: true}) .then(response => { this.$router.push({ name: 'accounts', params: { toRefresh: true } }) }) diff --git a/resources/js/views/auth/password/Request.vue b/resources/js/views/auth/password/Request.vue index 4ff4a419..18967531 100644 --- a/resources/js/views/auth/password/Request.vue +++ b/resources/js/views/auth/password/Request.vue @@ -23,7 +23,7 @@ handleSubmit(e) { e.preventDefault() - this.form.post('/api/user/password/lost', {returnError: true}) + this.form.post('/api/v1/user/password/lost', {returnError: true}) .then(response => { this.$notify({ type: 'is-success', text: response.data.message, duration:-1 }) diff --git a/resources/js/views/auth/password/Reset.vue b/resources/js/views/auth/password/Reset.vue index b1745d96..edd018d4 100644 --- a/resources/js/views/auth/password/Reset.vue +++ b/resources/js/views/auth/password/Reset.vue @@ -36,7 +36,7 @@ handleSubmit(e) { e.preventDefault() - this.form.post('/api/user/password/reset', {returnError: true}) + this.form.post('/api/v1/user/password/reset', {returnError: true}) .then(response => { this.$notify({ type: 'is-success', text: response.data.message, duration:-1 }) diff --git a/resources/js/views/groups/Create.vue b/resources/js/views/groups/Create.vue index 5ebce3e7..bc0d558f 100644 --- a/resources/js/views/groups/Create.vue +++ b/resources/js/views/groups/Create.vue @@ -31,7 +31,7 @@ async createGroup() { - await this.form.post('/api/groups') + await this.form.post('/api/v1/groups') if( this.form.errors.any() === false ) { this.$router.push({ name: 'groups' }); diff --git a/resources/js/views/groups/Edit.vue b/resources/js/views/groups/Edit.vue index 9e5a4e2b..754308bf 100644 --- a/resources/js/views/groups/Edit.vue +++ b/resources/js/views/groups/Edit.vue @@ -33,7 +33,7 @@ async updateGroup() { - await this.form.put('/api/groups/' + this.id) + await this.form.put('/api/v1/groups/' + this.id) if( this.form.errors.any() === false ) { this.$router.push({ name: 'groups' }) diff --git a/resources/js/views/settings/Account.vue b/resources/js/views/settings/Account.vue index 2a91326f..d09f0c27 100644 --- a/resources/js/views/settings/Account.vue +++ b/resources/js/views/settings/Account.vue @@ -51,7 +51,7 @@ }, async mounted() { - const { data } = await this.formProfile.get('/api/user') + const { data } = await this.formProfile.get('/api/v1/user') this.formProfile.fill(data) }, @@ -60,7 +60,7 @@ submitProfile(e) { e.preventDefault() - this.formProfile.put('/api/user', {returnError: true}) + this.formProfile.put('/api/v1/user', {returnError: true}) .then(response => { this.$notify({ type: 'is-success', text: this.$t('auth.forms.profile_saved') }) }) @@ -78,7 +78,7 @@ submitPassword(e) { e.preventDefault() - this.formPassword.patch('/api/user/password', {returnError: true}) + this.formPassword.patch('/api/v1/user/password', {returnError: true}) .then(response => { this.$notify({ type: 'is-success', text: response.data.message }) diff --git a/resources/js/views/settings/OAuth.vue b/resources/js/views/settings/OAuth.vue index 6a489892..55616417 100644 --- a/resources/js/views/settings/OAuth.vue +++ b/resources/js/views/settings/OAuth.vue @@ -74,7 +74,7 @@ this.isFetching = true - await this.axios.get('/api/oauth/personal-access-tokens').then(response => { + await this.axios.get('/api/v1/oauth/personal-access-tokens').then(response => { const tokens = [] response.data.forEach((data) => { @@ -108,7 +108,7 @@ async revokeToken(tokenId) { if(confirm(this.$t('settings.confirm.revoke'))) { - await this.axios.delete('/api/oauth/personal-access-tokens/' + tokenId).then(response => { + await this.axios.delete('/api/v1/oauth/personal-access-tokens/' + tokenId).then(response => { // Remove the revoked token from the collection this.tokens = this.tokens.filter(a => a.id !== tokenId) this.$notify({ type: 'is-success', text: this.$t('settings.token_revoked') }) diff --git a/resources/js/views/settings/Options.vue b/resources/js/views/settings/Options.vue index 2802fd51..1304000b 100644 --- a/resources/js/views/settings/Options.vue +++ b/resources/js/views/settings/Options.vue @@ -120,7 +120,7 @@ }, async mounted() { - const { data } = await this.form.get('/api/settings') + const { data } = await this.form.get('/api/v1/settings') this.form.fillWithKeyValueObject(data) this.form.lang = this.$root.$i18n.locale @@ -133,7 +133,7 @@ e.preventDefault() console.log(e) - // this.form.post('/api/settings/options', {returnError: false}) + // this.form.post('/api/v1/settings/options', {returnError: false}) // .then(response => { // this.$notify({ type: 'is-success', text: response.data.message }) @@ -149,7 +149,7 @@ saveSetting(settingName, event) { - this.axios.put('/api/settings/' + settingName, { value: event }).then(response => { + this.axios.put('/api/v1/settings/' + settingName, { value: event }).then(response => { this.$notify({ type: 'is-success', text: this.$t('settings.forms.setting_saved') }) if(settingName === 'lang' && response.data.value !== this.$root.$i18n.locale) { @@ -163,7 +163,7 @@ fetchGroups() { - this.axios.get('/api/groups').then(response => { + this.axios.get('/api/v1/groups').then(response => { response.data.forEach((data) => { if( data.id >0 ) { this.groups.push({ diff --git a/resources/js/views/settings/PATokens/Create.vue b/resources/js/views/settings/PATokens/Create.vue index 4fc8af93..03775234 100644 --- a/resources/js/views/settings/PATokens/Create.vue +++ b/resources/js/views/settings/PATokens/Create.vue @@ -31,7 +31,7 @@ async generatePAToken() { - const { data } = await this.form.post('/api/oauth/personal-access-tokens') + const { data } = await this.form.post('/api/v1/oauth/personal-access-tokens') if( this.form.errors.any() === false ) { this.$router.push({ name: 'settings.oauth', params: { accessToken: data.accessToken, token_id: data.token.id } }); diff --git a/resources/js/views/twofaccounts/Create.vue b/resources/js/views/twofaccounts/Create.vue index 6b042dd5..73cb5893 100644 --- a/resources/js/views/twofaccounts/Create.vue +++ b/resources/js/views/twofaccounts/Create.vue @@ -214,7 +214,7 @@ if( this.$route.params.decodedUri ) { // the Start view provided an uri so we parse it and prefill the quick form - this.axios.post('/api/twofaccounts/preview', { uri: this.$route.params.decodedUri }).then(response => { + this.axios.post('/api/v1/twofaccounts/preview', { uri: this.$route.params.decodedUri }).then(response => { this.form.fill(response.data) this.tempIcon = response.data.icon ? response.data.icon : null @@ -249,7 +249,7 @@ // set current temp icon as account icon this.form.icon = this.tempIcon - await this.form.post('/api/twofaccounts') + await this.form.post('/api/v1/twofaccounts') if( this.form.errors.any() === false ) { this.$router.push({name: 'accounts', params: { toRefresh: true }}); @@ -282,10 +282,10 @@ imgdata.append('inputFormat', 'fileUpload'); // First we get the uri encoded in the qrcode - const { data } = await this.form.upload('/api/qrcode/decode', imgdata) + const { data } = await this.form.upload('/api/v1/qrcode/decode', imgdata) // Then the otp described by the uri - this.axios.post('/api/twofaccounts/preview', { uri: data.data }).then(response => { + this.axios.post('/api/v1/twofaccounts/preview', { uri: data.data }).then(response => { this.form.fill(response.data) this.form.secretIsBase32Encoded = 1 this.tempIcon = response.data.icon ? response.data.icon : null @@ -300,7 +300,7 @@ let imgdata = new FormData(); imgdata.append('icon', this.$refs.iconInput.files[0]); - const { data } = await this.form.upload('/api/icons', imgdata) + const { data } = await this.form.upload('/api/v1/icons', imgdata) this.tempIcon = data.filename; @@ -308,7 +308,7 @@ deleteIcon(event) { if(this.tempIcon) { - this.axios.delete('/api/icons/' + this.tempIcon) + this.axios.delete('/api/v1/icons/' + this.tempIcon) this.tempIcon = '' } }, diff --git a/resources/js/views/twofaccounts/Edit.vue b/resources/js/views/twofaccounts/Edit.vue index 4deadfa3..115b3bd8 100644 --- a/resources/js/views/twofaccounts/Edit.vue +++ b/resources/js/views/twofaccounts/Edit.vue @@ -177,7 +177,7 @@ methods: { async getAccount () { - const { data } = await this.axios.get('/api/twofaccounts/' + this.$route.params.twofaccountId) + const { data } = await this.axios.get('/api/v1/twofaccounts/' + this.$route.params.twofaccountId) this.form.fill(data) this.form.secretIsBase32Encoded = 1 @@ -201,7 +201,7 @@ this.deleteIcon() } - await this.form.put('/api/twofaccounts/' + this.$route.params.twofaccountId) + await this.form.put('/api/v1/twofaccounts/' + this.$route.params.twofaccountId) if( this.form.errors.any() === false ) { this.$router.push({name: 'accounts', params: { InitialEditMode: true, toRefresh: true }}) @@ -228,7 +228,7 @@ let imgdata = new FormData(); imgdata.append('icon', this.$refs.iconInput.files[0]); - const { data } = await this.form.upload('/api/icons', imgdata) + const { data } = await this.form.upload('/api/v1/icons', imgdata) this.tempIcon = data; @@ -237,7 +237,7 @@ deleteIcon(event) { if( this.tempIcon && this.tempIcon !== this.form.icon ) { - this.axios.delete('/api/icons/' + this.tempIcon) + this.axios.delete('/api/v1/icons/' + this.tempIcon) } this.tempIcon = '' diff --git a/resources/js/views/twofaccounts/QRcode.vue b/resources/js/views/twofaccounts/QRcode.vue index 7278198e..8df83e2b 100644 --- a/resources/js/views/twofaccounts/QRcode.vue +++ b/resources/js/views/twofaccounts/QRcode.vue @@ -36,7 +36,7 @@ */ async getQRcode () { - const { data } = await this.axios.get('/api/twofaccounts/' + this.$route.params.twofaccountId + '/qrcode') + const { data } = await this.axios.get('/api/v1/twofaccounts/' + this.$route.params.twofaccountId + '/qrcode') this.qrcode = data.qrcode },