Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Krish Moodbidri
user-reg-cleanup
Commits
17966431
Commit
17966431
authored
Feb 27, 2020
by
Mitchell Moore
Committed by
Krish Moodbidri
Apr 10, 2020
Browse files
Fix variable mixup. Log Room ID to client console
parent
13f7b75e
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/templates/auth/SignUp.html
View file @
17966431
...
...
@@ -7,6 +7,7 @@
<script
src=
"static/scripts/function.js"
></script>
<script>
console
.
info
(
'
Room ID: {{ room_id }}
'
);
var
socket
=
io
.
connect
(
'
http://
'
+
document
.
domain
+
'
:
'
+
location
.
port
);
socket
.
on
(
'
connect
'
,
function
()
{
...
...
run.py
View file @
17966431
...
...
@@ -16,8 +16,8 @@ app = create_app(config_name)
app
.
config
[
'SECRET_KEY'
]
=
'vnkdjnfjknfl1232#'
socketio
=
SocketIO
(
app
)
global
username_global
global
room_global
#
global username_global
#
global room_global
def
create_account
(
username
,
fullname
,
reason
):
...
...
@@ -31,37 +31,39 @@ def create_account(username, fullname, reason):
def
account_agent
(
*
args
):
# Todo: Code to create a consumer based on the username goes here
# Todo: Goal is to have it listening for confirmation.
global
username_global
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
Account successfully created for '
+
username_global
)
socketio
.
emit
(
"account ready"
,
room
=
room_global
)
username
=
session
[
'username'
]
room
=
str
(
session
[
'uid'
])
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
Account successfully created for '
+
username
)
socketio
.
emit
(
"account ready"
,
room
=
room
)
return
True
@
socketio
.
on
(
'user connected'
)
def
user_connected
(
json
,
methods
=
[
'GET'
,
'POST'
]):
global
username_global
global
room_global
username
_global
=
json
[
"user"
]
room
_global
=
str
(
session
[
'uid'
])
username
=
json
[
"user"
]
room
=
str
(
session
[
'uid'
])
join_room
(
room
_global
)
join_room
(
room
)
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
User '
+
username
_global
+
' connected.'
)
print
(
'
\t\t\t
|-----Room ID: '
+
room
_global
)
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
User '
+
username
+
' connected.'
)
print
(
'
\t\t\t
|-----Room ID: '
+
room
)
@
socketio
.
on
(
'request account'
)
def
request_account
(
json
,
methods
=
[
'GET'
,
'POST'
]):
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
Queue request received: '
+
str
(
json
))
room
=
str
(
session
[
'uid'
])
try
:
# create_account(json['username'], json['fullname'], json['reason'])
tasks
.
celery_create_account
(
json
[
'username'
],
json
[
'fullname'
],
json
[
'reason'
],
room
_global
,
socketio
)
tasks
.
celery_create_account
(
json
[
'username'
],
json
[
'fullname'
],
json
[
'reason'
],
room
,
socketio
)
except
Exception
as
e
:
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
"
\t
Error in account creation: "
,
e
)
socketio
.
emit
(
"Account creation failed"
,
room
=
room_global
)
socketio
.
emit
(
"Account creation failed"
,
room
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Supports
Markdown
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