Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
7cf80289
Commit
7cf80289
authored
Jun 04, 2024
by
Timothy J. Baek
Browse files
fix: active users
parent
ab04e0df
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
backend/apps/socket/main.py
backend/apps/socket/main.py
+20
-0
src/routes/auth/+page.svelte
src/routes/auth/+page.svelte
+3
-1
No files found.
backend/apps/socket/main.py
View file @
7cf80289
...
...
@@ -31,6 +31,26 @@ async def connect(sid, environ, auth):
await
sio
.
emit
(
"user-count"
,
{
"count"
:
len
(
set
(
USER_POOL
))})
@
sio
.
on
(
"user-join"
)
async
def
user_join
(
sid
,
data
):
print
(
"user-join"
,
sid
,
data
)
auth
=
data
[
"auth"
]
if
"auth"
in
data
else
None
if
auth
and
"token"
in
auth
:
data
=
decode_token
(
auth
[
"token"
])
if
data
is
not
None
and
"id"
in
data
:
user
=
Users
.
get_user_by_id
(
data
[
"id"
])
if
user
:
USER_POOL
[
sid
]
=
user
.
id
print
(
f
"user
{
user
.
name
}
(
{
user
.
id
}
) connected with session ID
{
sid
}
"
)
print
(
len
(
set
(
USER_POOL
)))
await
sio
.
emit
(
"user-count"
,
{
"count"
:
len
(
set
(
USER_POOL
))})
@
sio
.
on
(
"user-count"
)
async
def
user_count
(
sid
):
print
(
"user-count"
,
sid
)
...
...
src/routes/auth/+page.svelte
View file @
7cf80289
...
...
@@ -3,7 +3,7 @@
import { userSignIn, userSignUp } from '$lib/apis/auths';
import Spinner from '$lib/components/common/Spinner.svelte';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { WEBUI_NAME, config, user } from '$lib/stores';
import { WEBUI_NAME, config, user
, socket
} from '$lib/stores';
import { onMount, getContext } from 'svelte';
import { toast } from 'svelte-sonner';
import { generateInitialsImage, canvasPixelTest } from '$lib/utils';
...
...
@@ -22,6 +22,8 @@
console.log(sessionUser);
toast.success($i18n.t(`You're now logged in.`));
localStorage.token = sessionUser.token;
$socket.emit('user-join', { auth: { token: sessionUser.token } });
await user.set(sessionUser);
goto('/');
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment