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
28445f36
Commit
28445f36
authored
Apr 20, 2020
by
Vladislav Rykov
Browse files
flashed messages added
parent
ff4a13ed
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/templates/layout.html
View file @
28445f36
...
@@ -39,6 +39,21 @@
...
@@ -39,6 +39,21 @@
<div
class=
"container"
>
<div
class=
"container"
>
{% block content %} {% endblock %}
{% block content %} {% endblock %}
<div
class=
"col-md-6 col-md-offset-3"
>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div
class=
"alert alert-{{ category }} alert-dismissiblei"
role=
"alert"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
aria-label=
"Close"
>
<span
aria-hidden=
"true"
>
×
</span>
</button>
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
</div>
</div>
<!-- /.container -->
</div>
<!-- /.container -->
<script
src=
"https://code.jquery.com/jquery-3.3.1.slim.min.js"
></script>
<script
src=
"https://code.jquery.com/jquery-3.3.1.slim.min.js"
></script>
...
...
app/views.py
View file @
28445f36
from
app
import
app
from
app
import
app
from
flask
import
render_template
,
request
,
redirect
,
url_for
,
session
,
send_from_directory
from
flask
import
render_template
,
request
,
redirect
,
url_for
,
session
,
send_from_directory
,
flash
import
psycopg2
import
psycopg2
import
app.dao.user.user
as
ud
import
app.dao.user.user
as
ud
...
@@ -41,13 +41,18 @@ def signup():
...
@@ -41,13 +41,18 @@ def signup():
if
(
username
==
''
or
password
==
''
):
if
(
username
==
''
or
password
==
''
):
feedback
=
'Username or password fields cannot be empty'
feedback
=
'Username or password fields cannot be empty'
return
render_template
(
'public/signup.html'
,
feedback
=
feedback
)
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
)
else
:
else
:
res
=
ud
.
create
(
username
,
password
)
res
=
ud
.
create
(
username
,
password
)
if
(
not
res
[
0
]):
if
(
not
res
[
0
]):
return
render_template
(
'public/signup.html'
,
feedback
=
res
[
1
])
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
else
:
else
:
session
[
'name'
]
=
username
session
[
'name'
]
=
username
flash
(
'User successfully created.'
,
'success'
)
return
redirect
(
url_for
(
'index'
))
return
redirect
(
url_for
(
'index'
))
...
@@ -61,12 +66,13 @@ def login():
...
@@ -61,12 +66,13 @@ def login():
password
=
request
.
form
[
'password'
].
encode
(
'utf-8'
)
password
=
request
.
form
[
'password'
].
encode
(
'utf-8'
)
if
(
username
==
''
or
password
==
''
):
if
(
username
==
''
or
password
==
''
):
f
eedback
=
'Username or password fields cannot be empty'
f
lash
(
'Username or password fields cannot be empty'
,
'danger'
)
return
re
nder_template
(
'public/login.html'
,
feedback
=
feedback
)
return
re
direct
(
request
.
url
)
else
:
else
:
res
=
ud
.
get
(
username
,
password
)
res
=
ud
.
get
(
username
,
password
)
if
(
not
res
[
0
]):
if
(
not
res
[
0
]):
return
render_template
(
'public/login.html'
,
feedback
=
msg
[
1
])
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
else
:
else
:
session
[
'name'
]
=
username
session
[
'name'
]
=
username
...
...
app/views.pyc
View file @
28445f36
No preview for this file type
config.py
View file @
28445f36
...
@@ -11,6 +11,7 @@ class Config(object):
...
@@ -11,6 +11,7 @@ class Config(object):
DB_PORT
=
5432
DB_PORT
=
5432
SESSION_COOKIE_SECURE
=
True
SESSION_COOKIE_SECURE
=
True
REMEMBER_COOKIE_SECURE
=
True
APPKEY_LENGTH
=
8
APPKEY_LENGTH
=
8
DATA_DOWNLOAD_DIR
=
'data'
DATA_DOWNLOAD_DIR
=
'data'
...
@@ -22,9 +23,11 @@ class DevelopmentConfig(Config):
...
@@ -22,9 +23,11 @@ class DevelopmentConfig(Config):
DEBUG
=
True
DEBUG
=
True
SESSION_COOKIE_SECURE
=
False
SESSION_COOKIE_SECURE
=
False
REMEMBER_COOKIE_SECURE
=
False
class
TestingConfig
(
Config
):
class
TestingConfig
(
Config
):
TESTING
=
True
TESTING
=
True
SESSION_COOKIE_SECURE
=
False
SESSION_COOKIE_SECURE
=
False
REMEMBER_COOKIE_SECURE
=
False
config.pyc
View file @
28445f36
No preview for this file type
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