Pass redirect URI from the App component rather than only having access to it in the login view.
This commit is contained in:
parent
7776ae80f0
commit
b76cb8070a
4 changed files with 26 additions and 9 deletions
|
|
@ -96,6 +96,10 @@ export default {
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
auth_redirect: {
|
||||
type: String,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
components: {
|
||||
icon: Icon,
|
||||
|
|
@ -174,7 +178,7 @@ export default {
|
|||
).then((response) => {
|
||||
if (response.error) {
|
||||
window.location.hash = ``;
|
||||
window.location.href = `${this.auth.redirect}?error=${encodeURI(response.error)}`;
|
||||
window.location.href = `${this.auth_redirect}?error=${encodeURI(response.error)}`;
|
||||
return
|
||||
}
|
||||
let data = response.data;
|
||||
|
|
@ -184,8 +188,9 @@ export default {
|
|||
this.user.image = data.images.length > 0 ? data.images[0].url : ``;
|
||||
|
||||
}).catch((err) => {
|
||||
console/error(err)
|
||||
window.location.hash = ``;
|
||||
window.location.href = `${this.auth.redirect}?error=${encodeURI(err)}`;;
|
||||
window.location.href = `${this.auth_redirect}?error=${encodeURI(err)}`;;
|
||||
return
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,11 +12,16 @@
|
|||
<script>
|
||||
export default {
|
||||
name: 'LoginView',
|
||||
props: {
|
||||
redirect: {
|
||||
type: String,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
data() { return {
|
||||
alert: `We will only be able to access your top tracks and artists, nothing else. This is also only done on your browser. Our servers do not see any of the data from your account.`,
|
||||
auth_base: `https://accounts.spotify.com/authorize`,
|
||||
use_state: process.env.NODE_ENV === `production`,
|
||||
redirect: process.env.NODE_ENV === `production` ? `https://oliver.akins.me/top-lists` : `http://localhost:8080`,
|
||||
client_id: `3a1795e9d55445b0aa0c05dd74c866fb`,
|
||||
scopes: [ `user-top-read` ],
|
||||
show_dialog: process.env.NODE_ENV !== `production`,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
:dev="dev_mode"
|
||||
:preview="preview_mode"
|
||||
:api_url="api_base"
|
||||
:auth_redirect="auth_redirect"
|
||||
:token="get_token()"
|
||||
:data_exists="data.length !== 0"
|
||||
@playlist_export="handle_export"
|
||||
|
|
@ -37,14 +38,15 @@ import UnknownTypeCard from "./cards/UnknownType.vue";
|
|||
export default {
|
||||
name: `MainView`,
|
||||
props: {
|
||||
preview_mode: Boolean,
|
||||
dev_mode: Boolean,
|
||||
auth_redirect: {
|
||||
type: String,
|
||||
required: true,
|
||||
}
|
||||
},
|
||||
components: {
|
||||
Control: ControlCard,
|
||||
Track: TrackCard,
|
||||
Artist: ArtistCard,
|
||||
Unknown: UnknownTypeCard,
|
||||
},
|
||||
data() { return {
|
||||
data: [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue