feat: block access for pin protected rooms
This commit is contained in:
parent
7587796934
commit
1063c239b6
3 changed files with 5 additions and 4 deletions
|
@ -1,8 +1,8 @@
|
|||
import { get_coords, type Coordinates } from "./gps"
|
||||
import { type Coordinates } from "./gps"
|
||||
import { parseSong, parseSuggestion, type FetchError, type Song, type Suggestion } from "./types"
|
||||
|
||||
export const joinRoom = async function (roomId: string, coords: Coordinates): Promise<[FetchError | null, string]> {
|
||||
let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}`)
|
||||
export const joinRoom = async function (roomId: string, coords: Coordinates, pin: string): Promise<[FetchError | null, string]> {
|
||||
let res = await fetch(`/api/join?room=${roomId}&lat=${coords.latitude}&lon=${coords.longitude}&pin=${pin}`)
|
||||
|
||||
if (res.status != 200) {
|
||||
return [{ code: 400, message: "Cannot join the room" }, ""]
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
|
||||
let sugg, queue, index
|
||||
;[returnError] = await joinRoom(data.roomId, coords)
|
||||
;[returnError] = await joinRoom(data.roomId, coords, data.pin)
|
||||
if (returnError) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3,5 +3,6 @@ import type { PageLoad } from "./$types"
|
|||
export const load: PageLoad = ({ params, url }) => {
|
||||
return {
|
||||
roomId: params.id || "",
|
||||
pin: url.searchParams.get("pin") || "",
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue