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
907ac1f3
Commit
907ac1f3
authored
Apr 22, 2020
by
Vladislav Rykov
Browse files
user roles + dafault user admin
parent
398a74a4
Changes
8
Hide whitespace changes
Inline
Side-by-side
app/__pycache__/config.cpython-35.pyc
View file @
907ac1f3
No preview for this file type
app/app/__pycache__/views.cpython-35.pyc
View file @
907ac1f3
No preview for this file type
app/app/dao/pend/__pycache__/pend.cpython-35.pyc
View file @
907ac1f3
No preview for this file type
app/app/dao/user/__pycache__/user.cpython-35.pyc
View file @
907ac1f3
No preview for this file type
app/app/dao/user/user.py
View file @
907ac1f3
...
...
@@ -3,14 +3,14 @@ import bcrypt
@
with_psql
def
create
(
cur
,
name
,
password
):
def
create
(
cur
,
name
,
password
,
role
):
query
=
"""
INSERT INTO
users
VALUES
(%s, %s)
(%s,
%s,
%s)
"""
cur
.
execute
(
query
,
(
name
,
bcrypt
.
hashpw
(
password
,
bcrypt
.
gensalt
())))
cur
.
execute
(
query
,
(
name
,
bcrypt
.
hashpw
(
password
,
bcrypt
.
gensalt
())
.
decode
(
'utf-8'
),
role
))
return
(
True
,)
@
with_psql
...
...
app/app/templates/layout.html
View file @
907ac1f3
...
...
@@ -40,6 +40,7 @@
<div
class=
"container"
>
{% block content %} {% endblock %}
<br><br>
<div
class=
"col-md-6 col-md-offset-3"
>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
...
...
app/app/views.py
View file @
907ac1f3
...
...
@@ -42,11 +42,11 @@ def signup():
if
(
username
==
''
or
password
==
''
):
feedback
=
'Username or password fields cannot be empty'
return
render_template
(
'public/signup.html'
,
feedback
=
feedback
)
elif
(
len
(
password
)
<
8
):
flash
(
'Password length must be at least 8 characters.'
,
'danger'
)
return
redirect
(
request
.
url
)
#
elif (len(password) < 8):
#
flash('Password length must be at least 8 characters.', 'danger')
#
return redirect(request.url)
else
:
res
=
ud
.
create
(
username
,
password
)
res
=
ud
.
create
(
username
,
password
,
'user'
)
if
(
not
res
[
0
]):
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
...
...
db.sql
View file @
907ac1f3
...
...
@@ -68,7 +68,8 @@ CREATE TABLE public.pend_msgs (
CREATE
TABLE
public
.
users
(
name
character
varying
(
30
)
NOT
NULL
,
password
character
varying
(
100
)
NOT
NULL
password
character
varying
(
100
)
NOT
NULL
,
role
character
varying
(
10
)
NOT
NULL
);
...
...
@@ -105,6 +106,7 @@ ALTER TABLE ONLY public.applications
ADD
CONSTRAINT
applications_username_fkey
FOREIGN
KEY
(
username
)
REFERENCES
public
.
users
(
name
);
INSERT
INTO
public
.
users
VALUES
(
'admin'
,
'$2b$12$chdF4ji1maIRLd4ms4s4yugFv.2BTvOAwiaWi6iRlTJzlGKjpTcA.'
,
'admin'
)
--
-- PostgreSQL database dump complete
--
...
...
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