Prevent open redirect on login
This commit is contained in:
parent
f78e3c6460
commit
1a362a2495
|
@ -1025,6 +1025,7 @@ export default new Router({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '*',
|
path: '*',
|
||||||
|
name: '404',
|
||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "core" */ '@/components/PageNotFound')
|
import(/* webpackChunkName: "core" */ '@/components/PageNotFound')
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,30 +3,40 @@
|
||||||
<section class="ui vertical stripe segment">
|
<section class="ui vertical stripe segment">
|
||||||
<div class="ui small text container">
|
<div class="ui small text container">
|
||||||
<h2><translate translate-context="Content/Login/Title/Verb">Log in to your Funkwhale account</translate></h2>
|
<h2><translate translate-context="Content/Login/Title/Verb">Log in to your Funkwhale account</translate></h2>
|
||||||
<login-form :next="next"></login-form>
|
<login-form :next="redirectTo"></login-form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LoginForm from "@/components/auth/LoginForm"
|
import LoginForm from '@/components/auth/LoginForm'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
next: { type: String, default: "/library" }
|
next: { type: String, default: '/library' }
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
redirectTo: this.next
|
||||||
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
LoginForm
|
LoginForm
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
const resolved = this.$router.resolve(this.redirectTo)
|
||||||
|
console.log(resolved.route.name)
|
||||||
|
if (resolved.route.name === '404') {
|
||||||
|
this.redirectTo = '/library'
|
||||||
|
}
|
||||||
if (this.$store.state.auth.authenticated) {
|
if (this.$store.state.auth.authenticated) {
|
||||||
this.$router.push(this.next)
|
this.$router.push(this.redirectTo)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
labels() {
|
labels () {
|
||||||
let title = this.$pgettext('Head/Login/Title', "Log In")
|
const title = this.$pgettext('Head/Login/Title', 'Log In')
|
||||||
return {
|
return {
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue