Skip to content
Snippets Groups Projects
Commit 20812731 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch 'feature/2-login-redirect' into 'develop'

Fixed #2: now redirect to previous page after login

Closes #2

See merge request funkwhale/funkwhale!26
parents 6274031f 80117212
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ Changelog
- Import: can now specify search template when querying import sources (#45)
- Player: better handling of errors when fetching the audio file (#46)
- Login form: now redirect to previous page after login (#2)
0.2.4 (2017-12-14)
......
......@@ -43,6 +43,9 @@ import auth from '@/auth'
export default {
name: 'login',
props: {
next: {type: String}
},
data () {
return {
// We need to initialize the component with any
......@@ -69,7 +72,7 @@ export default {
}
// We need to pass the component's this context
// to properly make use of http in the auth service
auth.login(this, credentials, {path: '/library'}, function (response) {
auth.login(this, credentials, {path: this.next}, function (response) {
// error callback
if (response.status === 400) {
self.error = 'invalid_credentials'
......
......@@ -32,7 +32,7 @@ Vue.http.interceptors.push(function (request, next) {
// redirect to login form when we get unauthorized response from server
if (response.status === 401) {
logger.default.warn('Received 401 response from API, redirecting to login form')
router.push({name: 'login'})
router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
}
})
})
......
......@@ -30,7 +30,8 @@ export default new Router({
{
path: '/login',
name: 'login',
component: Login
component: Login,
props: (route) => ({ next: route.query.next || '/library' })
},
{
path: '/logout',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment