Spaces:
Configuration error
Configuration error
Download src/utils/sessionManager.js from CPISTO/TARSTHENEXT: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/CPISTO/TARSTHENEXT/resolve/main/src/utils/sessionManager.js
- Command line
-
hf download hf://spaces/CPISTO/TARSTHENEXT/src/utils/sessionManager.js
-
curl -L -o sessionManager.js https://huggingface.co/spaces/CPISTO/TARSTHENEXT/resolve/main/src/utils/sessionManager.js
966 Bytes
| const usersKey = 'tars-users' | |
| const sessionKey = 'tars-session' | |
| export function getUsers() { | |
| return JSON.parse(localStorage.getItem(usersKey)) || [] | |
| } | |
| export function registerUser(username, password) { | |
| const users = getUsers() | |
| if (users.length >= 4) { | |
| return { error: 'Limite de 4 usuários atingido' } | |
| } | |
| if (users.find(u => u.username === username)) { | |
| return { error: 'Usuário já existe' } | |
| } | |
| const newUser = { username, password } | |
| users.push(newUser) | |
| localStorage.setItem(usersKey, JSON.stringify(users)) | |
| return { success: true } | |
| } | |
| export function loginUser(username, password) { | |
| const users = getUsers() | |
| const user = users.find(u => u.username === username && u.password === password) | |
| if (user) { | |
| localStorage.setItem(sessionKey, JSON.stringify(user)) | |
| return true | |
| } | |
| return false | |
| } | |
| export function getCurrentUser() { | |
| return JSON.parse(localStorage.getItem(sessionKey)) | |
| } | |