-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#38] use hashed-urls and therefore reimplements recall mechanism
- Loading branch information
Showing
12 changed files
with
159 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,5 +494,8 @@ | |
"others":{ | ||
"title": "Andere" | ||
} | ||
}, | ||
"recall": { | ||
"progress": "Einstellungen werden vorgenommen ..." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,5 +494,8 @@ | |
"others": { | ||
"title": "Others" | ||
} | ||
}, | ||
"recall": { | ||
"progress": "Settings will be applied ..." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,5 @@ | ||
import { Dropbox } from "dropbox"; | ||
export default function ({ store }) { | ||
//this middleware is only responsible for trigger refreshing the dropbox token | ||
|
||
const refreshToken = (store) => { | ||
let dpxAuth = store.getters['secrets/getDropboxAuth'] | ||
if(dpxAuth && dpxAuth.access_token) { | ||
let dbx = new Dropbox({ | ||
fetch: fetch, | ||
accessToken: dpxAuth.access_token, | ||
clientId: process.env.dropbox.clientId, | ||
}) | ||
|
||
dbx.usersGetCurrentAccount() | ||
.then(user => store.commit('secrets/setDropboxUser', user)) | ||
.catch(() => store.dispatch('secrets/removeDropboxAuth')) | ||
} | ||
} | ||
|
||
export default function ({ isHMR, app, store, route, params, error, redirect }) { | ||
//dropbox use a oath2 auth workflow. that means the user will be redirected | ||
//to the dropbox' login masked and after the login was successfully dropbox | ||
//redirects the user back to our web-app | ||
|
||
//this middleware is responsible for reading the dropbox auth token and store | ||
//them into our store | ||
|
||
let recall = route.query.recall && route.query.recall === 'dropbox' && route.hash | ||
if(!recall) { | ||
refreshToken(store) | ||
return | ||
} | ||
|
||
let hashParams = new URLSearchParams(route.hash.substring(1)) | ||
let authParams = {} | ||
for(let [key, value] of hashParams.entries()) { | ||
authParams[key] = value | ||
} | ||
|
||
store.dispatch('secrets/setDropboxAuth', authParams) | ||
.then(() => redirect(`/backup`)) | ||
.then(() => refreshToken(store)) | ||
store.dispatch('secrets/refreshDropboxToken') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default function (ctx) { | ||
//we need to handle requests which cannot handle fragments (url with #) | ||
//so this middleware will look the real url and check if there is a recall query | ||
//if so, redirect to own recall-page with all the origin data | ||
|
||
if(window.location.search) { | ||
let queryParams = new URLSearchParams(window.location.search.substr(1)) | ||
|
||
let recall = queryParams.has('recall') | ||
if(recall) { | ||
window.location = `${window.location.origin}${window.location.pathname}#/recall/${window.location.search}${window.location.hash}` | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<template> | ||
<v-container fill-height> | ||
<v-row align="center" | ||
justify="center"> | ||
<v-progress-circular | ||
:size="250" | ||
:width="10" | ||
color="primary" | ||
indeterminate | ||
class="text-center" | ||
> | ||
{{$t('recall.progress')}} | ||
</v-progress-circular> | ||
</v-row> | ||
</v-container> | ||
</template> | ||
|
||
<script> | ||
import { mapActions } from 'vuex'; | ||
export default { | ||
computed: { | ||
recall(){ | ||
return this.$route.query.recall | ||
} | ||
}, | ||
methods:{ | ||
...mapActions({ | ||
setDropboxAuth: 'secrets/setDropboxAuth', | ||
refreshDropboxToken: 'secrets/refreshDropboxToken', | ||
}), | ||
handleDropbox(){ | ||
//dropbox use a oath2 auth workflow. that means the user will be redirected | ||
//to the dropbox' login masked and after the login was successfully dropbox | ||
//redirects the user back to our web-app | ||
//this middleware is responsible for reading the dropbox auth token and store | ||
//them into our store | ||
let hashParams = new URLSearchParams(this.$route.hash.substring(2)) | ||
let authParams = {} | ||
for(let [key, value] of hashParams.entries()) { | ||
authParams[key] = value | ||
} | ||
this.setDropboxAuth(authParams) | ||
.then(() => this.refreshDropboxToken()) | ||
.then(() => this.$router.replace(`/backup?selected=4`)) //the 4th panel is dropbox | ||
} | ||
}, | ||
mounted() { | ||
switch (this.recall) { | ||
case 'dropbox': this.handleDropbox(); return | ||
default: { | ||
console.error("Unknown recall!") | ||
this.$router.replace('/') //goto home! | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
Oops, something went wrong.