Commit cec0dcfc authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch '119-login-redirection' into 'develop'

Fixed #119: forced redirection to login even with API_AUTHENTICATION_REQUIRED=False

Closes #119

See merge request funkwhale/funkwhale!91
parents b228a611 4298c423
......@@ -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']
......
Fixed forced redirection to login event with API_AUTHENTICATION_REQUIRED=False (#119)
......@@ -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'
......
......@@ -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
},
......
......@@ -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>
......
......@@ -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
})
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment