Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
account-app
Manage
Activity
Members
Labels
Plan
Issues
9
Issue boards
Milestones
Wiki
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
account-app
Commits
cf71a084
Commit
cf71a084
authored
4 years ago
by
Krish Moodbidri
Browse files
Options
Downloads
Patches
Plain Diff
pre-populate user information in the form
parent
304c663b
No related branches found
No related tags found
1 merge request
!6
Flask v0.1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/__init__.py
+24
-2
24 additions, 2 deletions
app/__init__.py
app/static/scripts/function.js
+21
-0
21 additions, 0 deletions
app/static/scripts/function.js
app/templates/auth/SignUp.html
+23
-15
23 additions, 15 deletions
app/templates/auth/SignUp.html
vars.py
+4
-1
4 additions, 1 deletion
vars.py
with
72 additions
and
18 deletions
app/__init__.py
+
24
−
2
View file @
cf71a084
...
...
@@ -9,26 +9,48 @@ import uuid
from
flask
import
Flask
,
redirect
,
url_for
,
request
,
render_template
,
flash
,
session
from
flask_bootstrap
import
Bootstrap
import
random
import
os
import
json
def
create_app
(
config_name
):
app
=
Flask
(
__name__
)
# initialization of the flask app
Bootstrap
(
app
)
# allowing app to use bootstrap
def
get_authorized_user
():
username_keys
=
list
(
filter
(
lambda
key
:
(
request
.
headers
.
get
(
key
)
is
not
None
),
vars
.
username_keys
))
fullname_keys
=
list
(
filter
(
lambda
key
:
(
request
.
headers
.
get
(
key
)
is
not
None
),
vars
.
fullname_keys
))
email_keys
=
list
(
filter
(
lambda
key
:
(
request
.
headers
.
get
(
key
)
is
not
None
),
vars
.
email_keys
))
user
=
{
"
username
"
:
(
request
.
headers
.
get
(
username_keys
[
0
])
if
len
(
username_keys
)
>
0
else
None
),
"
fullname
"
:
(
request
.
headers
.
get
(
fullname_keys
[
0
])
if
len
(
fullname_keys
)
>
0
else
None
),
"
email
"
:
(
request
.
headers
.
get
(
email_keys
[
0
])
if
len
(
email_keys
)
>
0
else
None
),
}
return
user
@app.route
(
'
/
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
# initial route to display the reg page
def
index
():
if
'
uid
'
not
in
session
:
session
[
'
uid
'
]
=
str
(
uuid
.
uuid4
())
if
'
user
'
not
in
session
:
session
[
"
user
"
]
=
get_authorized_user
()
if
"
redir
"
in
request
.
args
and
'
return_url
'
not
in
session
:
# check for redir arg in url
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
'
],
referrer
=
session
[
'
return_url
'
])
return
render_template
(
'
auth/SignUp.html
'
,
room_id
=
session
[
'
uid
'
],
username
=
session
[
'
user
'
].
get
(
'
username
'
),
fullname
=
session
[
'
user
'
].
get
(
'
fullname
'
),
email
=
session
[
'
user
'
].
get
(
'
email
'
),
referrer
=
session
[
'
return_url
'
],
cancel_url
=
vars
.
default_referrer
)
# misc page error catching
@app.errorhandler
(
403
)
...
...
This diff is collapsed.
Click to expand it.
app/static/scripts/function.js
+
21
−
0
View file @
cf71a084
...
...
@@ -14,3 +14,24 @@ function request_account() {
function
refresh
()
{
document
.
location
.
reload
(
true
);
}
function
autofill_form
(
username
,
fullname
,
email
)
{
let
username_input
=
document
.
getElementById
(
"
username
"
);
let
fullname_input
=
document
.
getElementById
(
"
fullname
"
);
let
email_input
=
document
.
getElementById
(
"
email
"
);
if
((
username
.
localeCompare
(
"
None
"
))
!==
0
)
{
username_input
.
value
=
username
;
username_input
.
disabled
=
"
true
"
;
}
if
((
fullname
.
localeCompare
(
"
None
"
))
!==
0
)
{
fullname_input
.
value
=
fullname
;
fullname_input
.
disabled
=
"
true
"
;
}
if
((
email
.
localeCompare
(
"
None
"
))
!==
0
)
{
email_input
.
value
=
email
;
email_input
.
disabled
=
"
true
"
;
}
}
This diff is collapsed.
Click to expand it.
app/templates/auth/SignUp.html
+
23
−
15
View file @
cf71a084
...
...
@@ -86,24 +86,32 @@
<!-- <h2>Hello, <span id="username">{{ user }}</span>!</h2> -->
<h2>
Hi,
</h2>
<div
id=
"test"
>
<form
action=
"."
method=
"post"
onsubmit=
""
>
<div
class=
"signUpContainer"
>
<label><b><label
for=
"username"
>
Blazer Id:
</label><br></b></label>
<input
class=
"form-control"
id=
"bid"
name=
"bid"
placeholder=
"Enter BlazerId"
required=
""
type=
"text"
>
<label><b><label
for=
"email"
>
Email Id:
</label><br></b></label>
<input
class=
"form-control"
id=
"email"
name=
"email"
placeholder=
"Enter Email Id"
required=
""
type=
"text"
pattern=
"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$"
>
<label><b><label
for=
"fullname"
>
Full Name:
</label><br></b></label>
<input
class=
"form-control"
id=
"fullname"
name=
"fullname"
placeholder=
"Enter Full Name"
required=
""
type=
"text"
>
<label><b><label
for=
"reason"
>
Reason for Requesting Account:
</label><br></b></label>
<textarea
class=
"form-control"
id=
"reason"
name=
"reason"
placeholder=
"Enter Reason for Account Request"
required=
""
></textarea>
<input
class=
"btn btn-primary btn-block"
id=
"submit"
name=
"submit"
type=
"button"
value=
"Submit"
onclick=
"request_account()"
>
<div>
<div
id=
"user-input"
>
<form
id=
"signup"
data-toggle=
"validator"
role=
"form"
action=
"."
method=
"post"
onsubmit=
""
>
<div
class=
"form-group"
>
<label
for=
"username"
class=
"control-label"
>
Blazer Id:
</label>
	
<input
id=
"username"
class=
"form-control"
placeholder=
"Enter Username"
required
><br>
</div>
<div
class=
"form-group"
>
<label
for=
"fullname"
class=
"control-label"
>
Full Name:
</label>
	
<input
id=
"fullname"
class=
"form-control"
placeholder=
"Enter Full Name"
required
><br>
</div>
<div
class=
"form-group"
>
<label
for=
"email"
class=
"control-label"
>
Email:
</label>
	
<input
id=
"email"
class=
"form-control"
placeholder=
"Enter Email"
required
><br>
</div>
<div
class=
"form-group"
>
<label
for=
"reason"
class=
"control-label"
>
Reason for Requesting Account:
</label><br>
<textarea
class=
"form-control"
id=
"reason"
name=
"reason"
placeholder=
"Enter Reason for Account Request"
required
></textarea>
</div>
<input
class=
"btn btn-primary btn-block"
id=
"submit"
name=
"submit"
type=
"button"
value=
"Submit"
onclick=
"request_account()"
>
<div>
<strong
id=
"error"
style=
"color: #be051b; text-align: center;"
></strong>
</div>
</div>
</form>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
vars.py
+
4
−
1
View file @
cf71a084
...
...
@@ -3,4 +3,7 @@ password = ''
key
=
''
broker_url
=
'
amqp://
'
+
id
+
'
:
'
+
password
+
'
@ohpc:5672/
'
message_queue
=
broker_url
+
'
socketio
'
default_referrer
=
"
/pun/sys/dashboard
"
default_referrer
=
"
/pun/sys/dashboard
"
username_keys
=
[
"
Remote-User
"
]
fullname_keys
=
[
"
HTTP_DISPLAYNAME
"
]
email_keys
=
[
"
HTTP_MAIL
"
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment