Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
rc
self-reg-form
Commits
b81897c3
Commit
b81897c3
authored
Mar 23, 2020
by
Mitchell Moore
Browse files
Implemented referrer to capture user entrypoint, to be used to redirect to on account creation
- Feat redirect - Fix redir logic
parent
9c756ddd
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/__init__.py
View file @
b81897c3
...
...
@@ -2,6 +2,7 @@
# local imports
from
__future__
import
print_function
import
vars
# third-party imports
import
uuid
...
...
@@ -21,9 +22,13 @@ def create_app(config_name):
session
[
'uid'
]
=
str
(
uuid
.
uuid4
())
if
"redir"
in
request
.
args
and
'return_url'
not
in
session
:
# check for redir arg in url
session
[
'return_url'
]
=
request
.
args
.
get
(
"redir"
)
or
"/pun/sys/dashboard"
session
[
'return_url'
]
=
request
.
args
.
get
(
"redir"
)
elif
"redir"
not
in
request
.
args
and
'return_url'
not
in
session
:
session
[
'return_url'
]
=
vars
.
default_referrer
else
:
session
[
'return_url'
]
=
request
.
referrer
return
render_template
(
'auth/SignUp.html'
,
room_id
=
session
[
'uid'
])
return
render_template
(
'auth/SignUp.html'
,
room_id
=
session
[
'uid'
]
,
referrer
=
session
[
'return_url'
]
)
# misc page error catching
@
app
.
errorhandler
(
403
)
...
...
app/templates/auth/SignUp.html
View file @
b81897c3
...
...
@@ -11,23 +11,26 @@
var
socket
=
io
.
connect
(
'
http://
'
+
document
.
domain
+
'
:
'
+
location
.
port
);
socket
.
on
(
'
connect
'
,
function
()
{
socket
.
emit
(
'
join_room
'
)
socket
.
emit
(
'
join_room
'
,
{
referrer
:
'
{{ referrer }}
'
});
socket
.
on
(
'
creating account
'
,
function
(
msg
)
{
document
.
getElementById
(
"
error
"
).
innerText
=
""
;
displayloading
();
})
})
;
socket
.
on
(
'
account ready
'
,
function
(
msg
)
{
$
(
'
#myModal
'
).
modal
(
'
hide
'
);
alert
(
"
Account has been created!
"
);
})
window
.
location
.
replace
(
'
{{ referrer }}
'
);
});
socket
.
on
(
'
Account creation failed
'
,
function
(
msg
)
{
document
.
getElementById
(
"
error
"
).
innerText
=
"
Registration Failed. Please try again.
"
;
})
})
;
})
})
;
</script>
<style
type=
"text/css"
>
...
...
@@ -130,4 +133,3 @@
</footer>
</body>
</html>
run.py
View file @
b81897c3
...
...
@@ -2,7 +2,6 @@
import
os
import
time
import
signal
import
tasks
import
vars
...
...
@@ -20,12 +19,15 @@ app.config['SECRET_KEY'] = vars.key
socketio
=
SocketIO
(
app
,
message_queue
=
vars
.
message_queue
)
@
socketio
.
on
(
'join_room'
)
def
on_room
():
def
on_room
(
json
):
room
=
str
(
session
[
'uid'
])
referrer
=
json
[
'referrer'
]
join_room
(
room
)
print
(
'
\t\t\t
|-----Room ID: '
+
room
)
print
(
'
\t\t\t
|-----Referrer: '
+
referrer
)
@
socketio
.
on
(
'request account'
)
...
...
tasks.py
View file @
b81897c3
...
...
@@ -12,10 +12,12 @@ celery = Celery('flask_user_reg', broker=broker_url)
socketio
=
SocketIO
(
message_queue
=
vars
.
message_queue
)
def
send_msg
(
event
,
room
):
print
(
"Post '{}' to room '{}'"
.
format
(
event
,
room
))
socketio
.
emit
(
event
,
room
=
room
)
@
celery
.
task
def
celery_create_account
(
username
,
fullname
,
reason
,
session
):
room
=
session
...
...
vars.py
View file @
b81897c3
...
...
@@ -3,3 +3,4 @@ password = 'reggie'
key
=
'vnkdjnfjknfl1232'
broker_url
=
'amqp://'
+
id
+
':'
+
password
+
'@ohpc:5672/'
message_queue
=
broker_url
+
'socketio'
default_referrer
=
"https://docs.uabgrid.uab.edu/wiki/Cheaha_Quick_Start"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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