new functions and js v=
This commit is contained in:
@@ -40,6 +40,16 @@ export function setNickname(value) {
|
||||
setNicknameCookie(nickname);
|
||||
}
|
||||
|
||||
const GUEST_ID_COOKIE = "rustpad_guest_id";
|
||||
export function getGuestId() {
|
||||
let guestId = getCookie(GUEST_ID_COOKIE);
|
||||
if (!/^[a-zA-Z0-9_-]{16,64}$/.test(guestId)) {
|
||||
guestId = crypto.randomUUID().replaceAll("-", "");
|
||||
document.cookie = `${GUEST_ID_COOKIE}=${guestId}; Path=/; SameSite=Lax`;
|
||||
}
|
||||
return guestId;
|
||||
}
|
||||
|
||||
const AUTH_TOKEN_KEY = "rustpad:auth-token";
|
||||
// Account sessions must be shared by every tab on this origin. Keep a
|
||||
// compatibility fallback for sessions created by older frontend versions.
|
||||
|
||||
Reference in New Issue
Block a user