Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladislav Rykov
THSO.server
Commits
ca4000a3
Commit
ca4000a3
authored
May 21, 2020
by
Vladislav Rykov
Browse files
register view integrated
parent
934b4f89
Changes
8
Show whitespace changes
Inline
Side-by-side
app/app/__pycache__/views.cpython-37.pyc
View file @
ca4000a3
No preview for this file type
app/app/dao/device/__pycache__/device.cpython-37.pyc
View file @
ca4000a3
No preview for this file type
app/app/dao/device/device.py
View file @
ca4000a3
...
@@ -7,7 +7,7 @@ def create_datatable(cur, appkey, dev_id):
...
@@ -7,7 +7,7 @@ def create_datatable(cur, appkey, dev_id):
cur
.
execute
(
cur
.
execute
(
sql
.
SQL
(
sql
.
SQL
(
"""CREATE TABLE {} (
"""CREATE TABLE {} (
utc NUMERIC(10) NOT NULL,
utc NUMERIC(10)
DEFAULT EXTRACT(EPOCH FROM now())::int
NOT NULL,
timedate VARCHAR(100) NOT NULL,
timedate VARCHAR(100) NOT NULL,
data json NOT NULL
data json NOT NULL
)"""
)"""
...
...
app/app/templates/new/examples/register.html
View file @
ca4000a3
app/app/templates/new/public/login.html
View file @
ca4000a3
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<!-- Navbar -->
<!-- Navbar -->
<nav
class=
"navbar navbar-top navbar-horizontal navbar-expand-md navbar-dark"
>
<nav
class=
"navbar navbar-top navbar-horizontal navbar-expand-md navbar-dark"
>
<div
class=
"container px-4"
>
<div
class=
"container px-4"
>
<a
class=
"navbar-brand"
href=
"../
index.html
"
>
<a
class=
"navbar-brand"
href=
"../"
>
<img
src=
"{{ url_for('static', filename='assets/img/brand/white.png') }}"
/>
<img
src=
"{{ url_for('static', filename='assets/img/brand/white.png') }}"
/>
</a>
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbar-collapse-main"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbar-collapse-main"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
...
@@ -34,12 +34,14 @@
...
@@ -34,12 +34,14 @@
</div>
</div>
<!-- Navbar items -->
<!-- Navbar items -->
<ul
class=
"navbar-nav ml-auto"
>
<ul
class=
"navbar-nav ml-auto"
>
{% if users_signup %}
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link nav-link-icon"
href=
"/
signup
"
>
<a
class=
"nav-link nav-link-icon"
href=
"/
register
"
>
<i
class=
"ni ni-circle-08"
></i>
<i
class=
"ni ni-circle-08"
></i>
<span
class=
"nav-link-inner--text"
>
Register
</span>
<span
class=
"nav-link-inner--text"
>
Register
</span>
</a>
</a>
</li>
</li>
{% endif %}
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link nav-link-icon"
href=
"/login"
>
<a
class=
"nav-link nav-link-icon"
href=
"/login"
>
<i
class=
"ni ni-key-25"
></i>
<i
class=
"ni ni-key-25"
></i>
...
@@ -111,7 +113,9 @@
...
@@ -111,7 +113,9 @@
<a
href=
"#"
class=
"text-light"
><small>
Forgot password?
</small></a>
<a
href=
"#"
class=
"text-light"
><small>
Forgot password?
</small></a>
</div>
</div>
<div
class=
"col-6 text-right"
>
<div
class=
"col-6 text-right"
>
{% if users_signup %}
<a
href=
"/register"
class=
"text-light"
><small>
Create new account
</small></a>
<a
href=
"/register"
class=
"text-light"
><small>
Create new account
</small></a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
...
...
app/app/templates/new/public/register.html
0 → 100644
View file @
ca4000a3
{% extends 'general_layout.html' %}
{% block title %} HPC
&
A IoT - Register {% endblock %}
{% block content %}
<body
class=
"bg-default"
>
<div
class=
"main-content"
>
<!-- Navbar -->
<nav
class=
"navbar navbar-top navbar-horizontal navbar-expand-md navbar-dark"
>
<div
class=
"container px-4"
>
<a
class=
"navbar-brand"
href=
"../"
>
<img
src=
"{{ url_for('static', filename='assets/img/brand/white.png') }}"
/>
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbar-collapse-main"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbar-collapse-main"
>
<!-- Collapse header -->
<div
class=
"navbar-collapse-header d-md-none"
>
<div
class=
"row"
>
<div
class=
"col-6 collapse-brand"
>
<a
href=
"../"
>
<img
src=
"{{ url_for('static', filename='assets/img/brand/blue.png') }}"
/>
</a>
</div>
<div
class=
"col-6 collapse-close"
>
<button
type=
"button"
class=
"navbar-toggler"
data-toggle=
"collapse"
data-target=
"#navbar-collapse-main"
aria-controls=
"sidenav-main"
aria-expanded=
"false"
aria-label=
"Toggle sidenav"
>
<span></span>
<span></span>
</button>
</div>
</div>
</div>
<!-- Navbar items -->
<ul
class=
"navbar-nav ml-auto"
>
{% if users_signup %}
<li
class=
"nav-item"
>
<a
class=
"nav-link nav-link-icon"
href=
"/register"
>
<i
class=
"ni ni-circle-08"
></i>
<span
class=
"nav-link-inner--text"
>
Register
</span>
</a>
</li>
{% endif %}
<li
class=
"nav-item"
>
<a
class=
"nav-link nav-link-icon"
href=
"/login"
>
<i
class=
"ni ni-key-25"
></i>
<span
class=
"nav-link-inner--text"
>
Login
</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Header -->
<div
class=
"header bg-gradient-primary py-7 py-lg-8"
>
<div
class=
"container"
>
<div
class=
"header-body text-center mb-7"
>
<div
class=
"row justify-content-center"
>
<div
class=
"col-lg-5 col-md-6"
>
<h1
class=
"text-white"
>
Welcome!
</h1>
<p
class=
"text-lead text-light"
>
Use these awesome forms to login or create new account in your project for free.
</p>
</div>
</div>
</div>
</div>
<div
class=
"separator separator-bottom separator-skew zindex-100"
>
<svg
x=
"0"
y=
"0"
viewBox=
"0 0 2560 100"
preserveAspectRatio=
"none"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
>
<polygon
class=
"fill-default"
points=
"2560 0 2560 100 0 100"
></polygon>
</svg>
</div>
</div>
<!-- Page content -->
<div
class=
"container mt--8 pb-5"
>
<!-- Table -->
<div
class=
"row justify-content-center"
>
<div
class=
"col-lg-6 col-md-8"
>
<div
class=
"card bg-secondary shadow border-0"
>
<div
class=
"card-body px-lg-5 py-lg-5"
>
<div
class=
"text-center text-muted mb-4"
>
<small>
Sign up with credentials
</small>
</div>
<form
role=
"form"
action=
"register"
method=
"post"
>
<div
class=
"form-group"
>
<div
class=
"input-group input-group-alternative mb-3"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
><i
class=
"ni ni-single-02"
></i></span>
</div>
<input
class=
"form-control"
maxlength=
"30"
placeholder=
"Username"
type=
"text"
id=
"username"
name=
"username"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"input-group input-group-alternative"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
><i
class=
"ni ni-lock-circle-open"
></i></span>
</div>
<input
class=
"form-control"
placeholder=
"Password"
type=
"password"
minlength=
"8"
id=
"password"
name=
"password"
onkeyup=
"return validate_password();"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"input-group input-group-alternative"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
><i
class=
"ni ni-lock-circle-open"
></i></span>
</div>
<input
class=
"form-control"
placeholder=
"Repeat password"
type=
"password"
minlength=
"8"
id=
"rpassword"
name=
"rpassword"
onkeyup=
"return validate_password();"
>
</div>
</div>
<div
class=
"text-muted font-italic"
><small>
Required password strength:
<span
class=
"text-success font-weight-700"
>
At least 8 characters.
</span></small></div>
<div
class=
"text-muted font-italic"
><small
id=
"passvalidation"
></small></div>
<div
class=
"text-center"
>
<button
type=
"sumbit"
id=
"submit"
class=
"btn btn-primary mt-4"
>
Create account
</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<script
type=
"text/javascript"
>
var
password
=
document
.
getElementById
(
"
password
"
);
var
rpassword
=
document
.
getElementById
(
"
rpassword
"
);
$
(
"
#submit
"
).
prop
(
"
disabled
"
,
true
);
function
validate_password
()
{
if
(
password
.
value
!=
rpassword
.
value
)
{
$
(
"
#passvalidation
"
).
html
(
"
<span class='text-danger font-weight-700'>Passwords do not match.</span>
"
);
$
(
"
#submit
"
).
prop
(
"
disabled
"
,
true
);
}
else
{
$
(
"
#passvalidation
"
).
html
(
"
<span class='text-success font-weight-700'>Passwords match.</span>
"
);
$
(
"
#submit
"
).
prop
(
"
disabled
"
,
false
);
}
}
</script>
{% endblock %}
app/app/templates/old/public/.signup.html.swp
0 → 100644
View file @
ca4000a3
File added
app/app/views.py
View file @
ca4000a3
...
@@ -40,18 +40,18 @@ def index():
...
@@ -40,18 +40,18 @@ def index():
@
app
.
route
(
'/
signup
'
,
methods
=
[
'GET'
,
'POST'
])
@
app
.
route
(
'/
register
'
,
methods
=
[
'GET'
,
'POST'
])
def
signup
():
def
signup
():
if
request
.
method
==
'GET'
:
if
request
.
method
==
'GET'
:
if
session
[
'role'
]
and
session
[
'role'
]
==
'admin'
:
if
'role'
in
session
and
session
[
'role'
]
==
'admin'
:
return
render_template
(
'old/admin/signup.html'
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
])
return
render_template
(
'old/admin/signup.html'
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
])
else
:
else
:
if
app
.
config
[
'USERS_SIGNUP'
]:
if
app
.
config
[
'USERS_SIGNUP'
]:
return
render_template
(
'
old
/public/
signup
.html'
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
])
return
render_template
(
'
new
/public/
register
.html'
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
])
else
:
else
:
return
redirect
(
url_for
(
'index'
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
]))
return
redirect
(
url_for
(
'index'
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
]))
else
:
else
:
if
app
.
config
[
'USERS_SIGNUP'
]
or
session
[
'role'
]
==
'admin'
:
if
app
.
config
[
'USERS_SIGNUP'
]
or
(
'role'
in
session
and
session
[
'role'
]
==
'admin'
)
:
username
=
request
.
form
[
'username'
]
username
=
request
.
form
[
'username'
]
password
=
request
.
form
[
'password'
].
encode
(
'utf-8'
)
password
=
request
.
form
[
'password'
].
encode
(
'utf-8'
)
...
@@ -63,7 +63,7 @@ def signup():
...
@@ -63,7 +63,7 @@ def signup():
return
redirect
(
request
.
url
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
])
return
redirect
(
request
.
url
,
users_signup
=
app
.
config
[
'USERS_SIGNUP'
])
else
:
else
:
role
=
'user'
role
=
'user'
if
request
.
form
[
'role'
]
and
request
.
form
[
'role'
]
==
'administrator'
:
if
'role'
in
request
.
form
and
request
.
form
[
'role'
]
==
'administrator'
:
role
=
'admin'
role
=
'admin'
res
=
ud
.
create
(
username
,
password
,
role
)
res
=
ud
.
create
(
username
,
password
,
role
)
...
@@ -75,7 +75,7 @@ def signup():
...
@@ -75,7 +75,7 @@ def signup():
flash
(
'User successfully created.'
,
'success'
)
flash
(
'User successfully created.'
,
'success'
)
if
session
[
'role'
]
and
session
[
'role'
]
==
'admin'
:
if
'role'
in
session
and
session
[
'role'
]
==
'admin'
:
return
redirect
(
url_for
(
'dashboard'
))
return
redirect
(
url_for
(
'dashboard'
))
else
:
else
:
return
redirect
(
url_for
(
'index'
))
return
redirect
(
url_for
(
'index'
))
...
@@ -86,7 +86,7 @@ def signup():
...
@@ -86,7 +86,7 @@ def signup():
@
app
.
route
(
'/login'
,
methods
=
[
'GET'
,
'POST'
])
@
app
.
route
(
'/login'
,
methods
=
[
'GET'
,
'POST'
])
def
login
():
def
login
():
if
request
.
method
==
'GET'
:
if
request
.
method
==
'GET'
:
return
render_template
(
'
old
/public/login.html'
)
return
render_template
(
'
new
/public/login.html'
)
else
:
else
:
username
=
request
.
form
[
'username'
]
username
=
request
.
form
[
'username'
]
password
=
request
.
form
[
'password'
].
encode
(
'utf-8'
)
password
=
request
.
form
[
'password'
].
encode
(
'utf-8'
)
...
...
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