Set up paths & namespace to match versioned routes

This commit is contained in:
Bubka 2021-11-07 21:57:22 +01:00
parent 0f17d93152
commit 7efa86b232
47 changed files with 98 additions and 94 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Controllers\Auth; namespace App\Api\v1\Controllers\Auth;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;

View File

@ -1,8 +1,8 @@
<?php <?php
namespace App\Http\Controllers\Auth; namespace App\Api\v1\Controllers\Auth;
use App\Http\Requests\UserPatchPwdRequest; use App\Api\v1\Requests\UserPatchPwdRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;

View File

@ -1,9 +1,9 @@
<?php <?php
namespace App\Http\Controllers\Auth; namespace App\Api\v1\Controllers\Auth;
use App\User; use App\User;
use App\Http\Requests\UserStoreRequest; use App\Api\v1\Requests\UserStoreRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Events\Registered;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Controllers\Auth; namespace App\Api\v1\Controllers\Auth;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Api\v1\Controllers; namespace App\Api\v1\Controllers\Auth;
use App\User; use App\User;
use App\Http\Requests\UserUpdateRequest; use App\Api\v1\Requests\UserUpdateRequest;
use App\Http\Resources\UserResource; use App\Api\v1\Resources\UserResource;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;

View File

@ -1,13 +1,14 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Api\v1\Controllers;
use App\Group; use App\Group;
use App\Services\GroupService; use App\Services\GroupService;
use App\Http\Requests\GroupStoreRequest; use App\Api\v1\Requests\GroupStoreRequest;
use App\Http\Requests\GroupAssignRequest; use App\Api\v1\Requests\GroupAssignRequest;
use App\Http\Resources\GroupResource; use App\Api\v1\Resources\GroupResource;
use App\Http\Resources\TwoFAccountCollection; use App\Api\v1\Resources\TwoFAccountCollection;
use App\Http\Controllers\Controller;
class GroupController extends Controller class GroupController extends Controller
{ {

View File

@ -1,9 +1,10 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Api\v1\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use App\Http\Controllers\Controller;
class IconController extends Controller class IconController extends Controller

View File

@ -1,11 +1,12 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Api\v1\Controllers;
use App\TwoFAccount; use App\TwoFAccount;
use App\Services\QrCodeService; use App\Services\QrCodeService;
use App\Services\TwoFAccountService; use App\Services\TwoFAccountService;
use App\Http\Requests\QrCodeDecodeRequest; use App\Api\v1\Requests\QrCodeDecodeRequest;
use App\Http\Controllers\Controller;
class QrCodeController extends Controller class QrCodeController extends Controller

View File

@ -1,12 +1,12 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Api\v1\Controllers;
use App\Exceptions\DbEncryptionException; use App\Exceptions\DbEncryptionException;
use App\Services\DbEncryptionService; use App\Services\DbEncryptionService;
use App\Services\SettingServiceInterface; use App\Services\SettingServiceInterface;
use App\Http\Requests\SettingStoreRequest; use App\Api\v1\Requests\SettingStoreRequest;
use App\Http\Requests\SettingUpdateRequest; use App\Api\v1\Requests\SettingUpdateRequest;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;

View File

@ -1,22 +1,23 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Api\v1\Controllers;
use App\TwoFAccount; use App\TwoFAccount;
use App\Exceptions\UndecipherableException; use App\Exceptions\UndecipherableException;
use App\Http\Requests\TwoFAccountReorderRequest; use App\Api\v1\Requests\TwoFAccountReorderRequest;
use App\Http\Requests\TwoFAccountStoreRequest; use App\Api\v1\Requests\TwoFAccountStoreRequest;
use App\Http\Requests\TwoFAccountUpdateRequest; use App\Api\v1\Requests\TwoFAccountUpdateRequest;
use App\Http\Requests\TwoFAccountBatchRequest; use App\Api\v1\Requests\TwoFAccountBatchRequest;
use App\Http\Requests\TwoFAccountUriRequest; use App\Api\v1\Requests\TwoFAccountUriRequest;
use App\Http\Requests\TwoFAccountDynamicRequest; use App\Api\v1\Requests\TwoFAccountDynamicRequest;
use App\Http\Resources\TwoFAccountCollection; use App\Api\v1\Resources\TwoFAccountCollection;
use App\Http\Resources\TwoFAccountReadResource; use App\Api\v1\Resources\TwoFAccountReadResource;
use App\Http\Resources\TwoFAccountStoreResource; use App\Api\v1\Resources\TwoFAccountStoreResource;
use App\Services\GroupService; use App\Services\GroupService;
use App\Services\TwoFAccountService; use App\Services\TwoFAccountService;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class TwoFAccountController extends Controller class TwoFAccountController extends Controller
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Requests; namespace App\Api\v1\Requests;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Resources; namespace App\Api\v1\Resources;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Resources; namespace App\Api\v1\Resources;
use Illuminate\Http\Resources\Json\ResourceCollection; use Illuminate\Http\Resources\Json\ResourceCollection;
@ -11,7 +11,7 @@ class TwoFAccountCollection extends ResourceCollection
* *
* @var string * @var string
*/ */
public $collects = 'App\Http\Resources\TwoFAccountReadResource'; public $collects = 'App\Api\v1\Resources\TwoFAccountReadResource';
/** /**

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Resources; namespace App\Api\v1\Resources;
class TwoFAccountReadResource extends TwoFAccountStoreResource class TwoFAccountReadResource extends TwoFAccountStoreResource
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Resources; namespace App\Api\v1\Resources;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Http\Resources; namespace App\Api\v1\Resources;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;

View File

@ -35,11 +35,11 @@ class RouteServiceProvider extends ServiceProvider
*/ */
public function map() public function map()
{ {
$this->mapWebRoutes();
$this->mapApiVersionOneRoutes(); $this->mapApiVersionOneRoutes();
// $this->mapApiVersionTwoRoutes(); // $this->mapApiVersionTwoRoutes();
$this->mapWebRoutes();
} }
/** /**

View File

@ -94,7 +94,7 @@
if( id ) { if( id ) {
this.internal_id = 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_service = data.service
this.internal_account = data.account this.internal_account = data.account
@ -132,17 +132,17 @@
getOtp: async function() { getOtp: async function() {
if(this.internal_id) { 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 return data
} }
else if(this.internal_uri) { 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 uri: this.internal_uri
}) })
return data return data
} }
else { else {
const { data } = await this.axios.post('/api/twofaccounts/otp', { const { data } = await this.axios.post('/api/v1/twofaccounts/otp', {
service : this.internal_service, service : this.internal_service,
account : this.internal_account, account : this.internal_account,
icon : this.internal_icon, icon : this.internal_icon,

View File

@ -347,7 +347,7 @@
let accounts = [] let accounts = []
this.selectedAccounts = [] this.selectedAccounts = []
this.axios.get('api/twofaccounts').then(response => { this.axios.get('api/v1/twofaccounts').then(response => {
response.data.forEach((data) => { response.data.forEach((data) => {
accounts.push(data) accounts.push(data)
}) })
@ -393,7 +393,7 @@
*/ */
saveOrder() { saveOrder() {
this.drag = false 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)) this.selectedAccounts.forEach(id => ids.push(id))
// Backend will delete all accounts at the same time // 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 // we fetch the accounts again to prevent the js collection being
// desynchronize from the backend php collection // desynchronize from the backend php collection
@ -425,9 +425,9 @@
// Backend will associate all accounts with the selected group in the same move // Backend will associate all accounts with the selected group in the same move
// or withdraw the accounts if destination is 'no group' (id = 0) // or withdraw the accounts if destination is 'no group' (id = 0)
if(this.moveAccountsTo === 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 // we fetch the accounts again to prevent the js collection being
// desynchronize from the backend php collection // desynchronize from the backend php collection
@ -443,7 +443,7 @@
fetchGroups() { fetchGroups() {
let groups = [] let groups = []
this.axios.get('api/groups').then(response => { this.axios.get('api/v1/groups').then(response => {
response.data.forEach((data) => { response.data.forEach((data) => {
groups.push(data) groups.push(data)
}) })
@ -466,7 +466,7 @@
// In db saving if the user set 2FAuth to memorize the active group // In db saving if the user set 2FAuth to memorize the active group
if( this.$root.appSettings.rememberActiveGroup ) { if( this.$root.appSettings.rememberActiveGroup ) {
this.form.put('/api/settings/activeGroup', {returnError: true}) this.form.put('/api/v1/settings/activeGroup', {returnError: true})
.then(response => { .then(response => {
// everything's fine // everything's fine
}) })

View File

@ -79,7 +79,7 @@
this.isFetching = true this.isFetching = true
await this.axios.get('api/groups').then(response => { await this.axios.get('api/v1/groups').then(response => {
const groups = [] const groups = []
response.data.forEach((data) => { response.data.forEach((data) => {
@ -101,7 +101,7 @@
*/ */
deleteGroup(id) { deleteGroup(id) {
if(confirm(this.$t('groups.confirm.delete'))) { 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 // Remove the deleted group from the collection
this.groups = this.groups.filter(a => a.id !== id) this.groups = this.groups.filter(a => a.id !== id)

View File

@ -79,7 +79,7 @@
mounted() { mounted() {
this.axios.get('api/twofaccounts/count').then(response => { this.axios.get('api/v1/twofaccounts/count').then(response => {
this.accountCount = response.data.count this.accountCount = response.data.count
}) })
}, },
@ -105,7 +105,7 @@
imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]); imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]);
imgdata.append('inputFormat', 'fileUpload'); 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 } }); this.$router.push({ name: 'createAccount', params: { decodedUri: data.data } });
}, },

View File

@ -61,7 +61,7 @@
// } // }
next(async vm => { 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 ) { if( data.name ) {
vm.username = data.name vm.username = data.name

View File

@ -31,7 +31,7 @@
async handleSubmit(e) { async handleSubmit(e) {
e.preventDefault() e.preventDefault()
this.form.post('/api/user', {returnError: true}) this.form.post('/api/v1/user', {returnError: true})
.then(response => { .then(response => {
this.$router.push({ name: 'accounts', params: { toRefresh: true } }) this.$router.push({ name: 'accounts', params: { toRefresh: true } })
}) })

View File

@ -23,7 +23,7 @@
handleSubmit(e) { handleSubmit(e) {
e.preventDefault() e.preventDefault()
this.form.post('/api/user/password/lost', {returnError: true}) this.form.post('/api/v1/user/password/lost', {returnError: true})
.then(response => { .then(response => {
this.$notify({ type: 'is-success', text: response.data.message, duration:-1 }) this.$notify({ type: 'is-success', text: response.data.message, duration:-1 })

View File

@ -36,7 +36,7 @@
handleSubmit(e) { handleSubmit(e) {
e.preventDefault() e.preventDefault()
this.form.post('/api/user/password/reset', {returnError: true}) this.form.post('/api/v1/user/password/reset', {returnError: true})
.then(response => { .then(response => {
this.$notify({ type: 'is-success', text: response.data.message, duration:-1 }) this.$notify({ type: 'is-success', text: response.data.message, duration:-1 })

View File

@ -31,7 +31,7 @@
async createGroup() { async createGroup() {
await this.form.post('/api/groups') await this.form.post('/api/v1/groups')
if( this.form.errors.any() === false ) { if( this.form.errors.any() === false ) {
this.$router.push({ name: 'groups' }); this.$router.push({ name: 'groups' });

View File

@ -33,7 +33,7 @@
async updateGroup() { 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 ) { if( this.form.errors.any() === false ) {
this.$router.push({ name: 'groups' }) this.$router.push({ name: 'groups' })

View File

@ -51,7 +51,7 @@
}, },
async mounted() { async mounted() {
const { data } = await this.formProfile.get('/api/user') const { data } = await this.formProfile.get('/api/v1/user')
this.formProfile.fill(data) this.formProfile.fill(data)
}, },
@ -60,7 +60,7 @@
submitProfile(e) { submitProfile(e) {
e.preventDefault() e.preventDefault()
this.formProfile.put('/api/user', {returnError: true}) this.formProfile.put('/api/v1/user', {returnError: true})
.then(response => { .then(response => {
this.$notify({ type: 'is-success', text: this.$t('auth.forms.profile_saved') }) this.$notify({ type: 'is-success', text: this.$t('auth.forms.profile_saved') })
}) })
@ -78,7 +78,7 @@
submitPassword(e) { submitPassword(e) {
e.preventDefault() e.preventDefault()
this.formPassword.patch('/api/user/password', {returnError: true}) this.formPassword.patch('/api/v1/user/password', {returnError: true})
.then(response => { .then(response => {
this.$notify({ type: 'is-success', text: response.data.message }) this.$notify({ type: 'is-success', text: response.data.message })

View File

@ -74,7 +74,7 @@
this.isFetching = true 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 = [] const tokens = []
response.data.forEach((data) => { response.data.forEach((data) => {
@ -108,7 +108,7 @@
async revokeToken(tokenId) { async revokeToken(tokenId) {
if(confirm(this.$t('settings.confirm.revoke'))) { 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 // Remove the revoked token from the collection
this.tokens = this.tokens.filter(a => a.id !== tokenId) this.tokens = this.tokens.filter(a => a.id !== tokenId)
this.$notify({ type: 'is-success', text: this.$t('settings.token_revoked') }) this.$notify({ type: 'is-success', text: this.$t('settings.token_revoked') })

View File

@ -120,7 +120,7 @@
}, },
async mounted() { 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.fillWithKeyValueObject(data)
this.form.lang = this.$root.$i18n.locale this.form.lang = this.$root.$i18n.locale
@ -133,7 +133,7 @@
e.preventDefault() e.preventDefault()
console.log(e) console.log(e)
// this.form.post('/api/settings/options', {returnError: false}) // this.form.post('/api/v1/settings/options', {returnError: false})
// .then(response => { // .then(response => {
// this.$notify({ type: 'is-success', text: response.data.message }) // this.$notify({ type: 'is-success', text: response.data.message })
@ -149,7 +149,7 @@
saveSetting(settingName, event) { 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') }) this.$notify({ type: 'is-success', text: this.$t('settings.forms.setting_saved') })
if(settingName === 'lang' && response.data.value !== this.$root.$i18n.locale) { if(settingName === 'lang' && response.data.value !== this.$root.$i18n.locale) {
@ -163,7 +163,7 @@
fetchGroups() { fetchGroups() {
this.axios.get('/api/groups').then(response => { this.axios.get('/api/v1/groups').then(response => {
response.data.forEach((data) => { response.data.forEach((data) => {
if( data.id >0 ) { if( data.id >0 ) {
this.groups.push({ this.groups.push({

View File

@ -31,7 +31,7 @@
async generatePAToken() { 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 ) { if( this.form.errors.any() === false ) {
this.$router.push({ name: 'settings.oauth', params: { accessToken: data.accessToken, token_id: data.token.id } }); this.$router.push({ name: 'settings.oauth', params: { accessToken: data.accessToken, token_id: data.token.id } });

View File

@ -214,7 +214,7 @@
if( this.$route.params.decodedUri ) { if( this.$route.params.decodedUri ) {
// the Start view provided an uri so we parse it and prefill the quick form // 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.form.fill(response.data)
this.tempIcon = response.data.icon ? response.data.icon : null this.tempIcon = response.data.icon ? response.data.icon : null
@ -249,7 +249,7 @@
// set current temp icon as account icon // set current temp icon as account icon
this.form.icon = this.tempIcon this.form.icon = this.tempIcon
await this.form.post('/api/twofaccounts') await this.form.post('/api/v1/twofaccounts')
if( this.form.errors.any() === false ) { if( this.form.errors.any() === false ) {
this.$router.push({name: 'accounts', params: { toRefresh: true }}); this.$router.push({name: 'accounts', params: { toRefresh: true }});
@ -282,10 +282,10 @@
imgdata.append('inputFormat', 'fileUpload'); imgdata.append('inputFormat', 'fileUpload');
// First we get the uri encoded in the qrcode // 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 // 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.fill(response.data)
this.form.secretIsBase32Encoded = 1 this.form.secretIsBase32Encoded = 1
this.tempIcon = response.data.icon ? response.data.icon : null this.tempIcon = response.data.icon ? response.data.icon : null
@ -300,7 +300,7 @@
let imgdata = new FormData(); let imgdata = new FormData();
imgdata.append('icon', this.$refs.iconInput.files[0]); 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; this.tempIcon = data.filename;
@ -308,7 +308,7 @@
deleteIcon(event) { deleteIcon(event) {
if(this.tempIcon) { if(this.tempIcon) {
this.axios.delete('/api/icons/' + this.tempIcon) this.axios.delete('/api/v1/icons/' + this.tempIcon)
this.tempIcon = '' this.tempIcon = ''
} }
}, },

View File

@ -177,7 +177,7 @@
methods: { methods: {
async getAccount () { 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.fill(data)
this.form.secretIsBase32Encoded = 1 this.form.secretIsBase32Encoded = 1
@ -201,7 +201,7 @@
this.deleteIcon() 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 ) { if( this.form.errors.any() === false ) {
this.$router.push({name: 'accounts', params: { InitialEditMode: true, toRefresh: true }}) this.$router.push({name: 'accounts', params: { InitialEditMode: true, toRefresh: true }})
@ -228,7 +228,7 @@
let imgdata = new FormData(); let imgdata = new FormData();
imgdata.append('icon', this.$refs.iconInput.files[0]); 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; this.tempIcon = data;
@ -237,7 +237,7 @@
deleteIcon(event) { deleteIcon(event) {
if( this.tempIcon && this.tempIcon !== this.form.icon ) { 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 = '' this.tempIcon = ''

View File

@ -36,7 +36,7 @@
*/ */
async getQRcode () { 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 this.qrcode = data.qrcode
}, },