Commit 1104e8ae authored by Aral Balkan's avatar Aral Balkan
Browse files

Sign in works

parent 1dd67ae5
module.exports = (socket, request) => {
console.log('Private socket connection request. Token = ', request.params.token)
if (!db.privateRoutes) {
db.privateRoutes = []
}
let authorised = false
db.privateRoutes.forEach(route => {
if (route.route === request.params.token) {
authorised = true
route.accessedAt = new Date()
}
})
if (!authorised) {
socket.close()
} else {
// TODO: add client to room, etc., etc.
socket.send('Hello, welcome to the private area! Oooh!!!!')
}
}
<script>
import Section from './Section.interface'
import { getContext } from 'svelte'
import { get } from 'svelte/store'
import { state } from '../state.js'
const { privatePath } = getContext(state)
async function onShow() {
console.log('Attempting to connect using private token', get(privatePath))
// Create a web socket connection.
const privateSocket = new WebSocket(`wss://${location.hostname}/private/${get(privatePath)}`)
privateSocket.onmessage = message => {
console.log('Got message', message)
}
return ''
}
</script>
<Section path='/private' title='Private'>
{ onShow() }
<p>This is private.</p>
</Section>
......@@ -17,8 +17,8 @@
passphraseField.focus()
}
function signInSucceeded(){
$privatePath = _privatePath
async function signInSucceeded(){
$privatePath = await _privatePath
// Once we’ve stored the promise, unset it here so that
// it is not persisted on the view. (Otherwise, after signing out,
// it will return here and find the successful sign in.)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment