diff --git a/api/funkwhale_api/music/views.py b/api/funkwhale_api/music/views.py index 78a3588762716759c21ebbf59d265d0bb90bc558..0d33855a6b09060eb5094f8b56aaac9aac641a89 100644 --- a/api/funkwhale_api/music/views.py +++ b/api/funkwhale_api/music/views.py @@ -240,6 +240,7 @@ class TagViewSet(viewsets.ReadOnlyModelViewSet): class Search(views.APIView): max_results = 3 + permission_classes = [ConditionalAuthentication] def get(self, request, *args, **kwargs): query = request.GET['query'] diff --git a/changes/changelog.d/119.bugfix b/changes/changelog.d/119.bugfix new file mode 100644 index 0000000000000000000000000000000000000000..b2e7ff71f4c93f1858d7a71ffca69e9a573421e7 --- /dev/null +++ b/changes/changelog.d/119.bugfix @@ -0,0 +1 @@ +Fixed forced redirection to login event with API_AUTHENTICATION_REQUIRED=False (#119) diff --git a/front/src/App.vue b/front/src/App.vue index b26959fe7006a72c45cac37e72d468c8f3c614ff..347f19e30ebbf071bb4c5014649d81650942c84b 100644 --- a/front/src/App.vue +++ b/front/src/App.vue @@ -56,6 +56,9 @@ export default { }, methods: { openWebsocket () { + if (!this.$store.state.auth.authenticated) { + return + } let self = this let token = this.$store.state.auth.token // let token = 'test' diff --git a/front/src/components/audio/SearchBar.vue b/front/src/components/audio/SearchBar.vue index 988ff0a7d7ccb78707e3b66c3474e380e6838e72..99896d04beda7bc51a559fb10b8205a45e254610 100644 --- a/front/src/components/audio/SearchBar.vue +++ b/front/src/components/audio/SearchBar.vue @@ -30,6 +30,9 @@ export default { }, apiSettings: { beforeXHR: function (xhrObject) { + if (!self.$store.state.auth.authenticated) { + return xhrObject + } xhrObject.setRequestHeader('Authorization', self.$store.getters['auth/header']) return xhrObject }, diff --git a/front/src/components/library/Home.vue b/front/src/components/library/Home.vue index e4e22fc09919f815038795762f408ac0a760aa58..40f6808f98f3c382353fd9bb205d3c09cbbcb8bd 100644 --- a/front/src/components/library/Home.vue +++ b/front/src/components/library/Home.vue @@ -20,7 +20,7 @@ </div> <div class="column"> <h2 class="ui header">Music requests</h2> - <request-form></request-form> + <request-form v-if="$store.state.auth.authenticated"></request-form> </div> </div> </div> diff --git a/front/src/components/library/Library.vue b/front/src/components/library/Library.vue index 6cd156493f4487683df91fd9314f31fb8807de1d..c209221274940f7fa73763cffa3f9566855cafa8 100644 --- a/front/src/components/library/Library.vue +++ b/front/src/components/library/Library.vue @@ -5,7 +5,7 @@ <router-link class="ui item" to="/library/artists" exact>Artists</router-link> <router-link class="ui item" to="/library/radios" exact>Radios</router-link> <div class="ui secondary right menu"> - <router-link class="ui item" to="/library/requests/" exact> + <router-link v-if="$store.state.auth.authenticated" class="ui item" to="/library/requests/" exact> Requests <div class="ui teal label">{{ requestsCount }}</div> </router-link> @@ -32,8 +32,11 @@ export default { }, methods: { fetchRequestsCount () { + if (!this.$store.state.authenticated) { + return + } let self = this - axios.get('requests/import-requests', {params: {status: 'pending'}}).then(response => { + axios.get('requests/import-requests/', {params: {status: 'pending'}}).then(response => { self.requestsCount = response.data.count }) }