Pinafore-Web-Client-Frontend/src/routes/settings/quick-login.html

34 lines
875 B
HTML

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