pinafore/src/routes/settings/quick-login.html

33 lines
830 B
HTML
Raw Normal View History

<!-- this is only used in the tests, to log in quickly -->
<script>
import { store } from '../_store/store'
import { goto } from '../../../__sapper__/client'
export default {
oncreate () {
let accessToken = location.search.match(/accessToken=([^&]+)/)[1]
let instanceName = location.search.match(/instanceName=([^&]+)/)[1]
let {
loggedInInstances,
loggedInInstancesInOrder
} = store.get()
loggedInInstances[instanceName] = {
access_token: accessToken
}
if (!loggedInInstancesInOrder.includes(instanceName)) {
loggedInInstancesInOrder.push(instanceName)
}
store.set({
currentInstance: instanceName,
loggedInInstances,
loggedInInstancesInOrder
})
store.save()
goto('/')
}
}
</script>