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 @@
<div
class=
"container"
>
{% 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 -->
<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
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
app.dao.user.user
as
ud
...
...
@@ -41,13 +41,18 @@ 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
)
else
:
res
=
ud
.
create
(
username
,
password
)
if
(
not
res
[
0
]):
return
render_template
(
'public/signup.html'
,
feedback
=
res
[
1
])
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
else
:
session
[
'name'
]
=
username
flash
(
'User successfully created.'
,
'success'
)
return
redirect
(
url_for
(
'index'
))
...
...
@@ -61,12 +66,13 @@ def login():
password
=
request
.
form
[
'password'
].
encode
(
'utf-8'
)
if
(
username
==
''
or
password
==
''
):
f
eedback
=
'Username or password fields cannot be empty'
return
re
nder_template
(
'public/login.html'
,
feedback
=
feedback
)
f
lash
(
'Username or password fields cannot be empty'
,
'danger'
)
return
re
direct
(
request
.
url
)
else
:
res
=
ud
.
get
(
username
,
password
)
if
(
not
res
[
0
]):
return
render_template
(
'public/login.html'
,
feedback
=
msg
[
1
])
flash
(
'Error: {}'
.
format
(
res
[
1
]),
'danger'
)
return
redirect
(
request
.
url
)
else
:
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):
DB_PORT
=
5432
SESSION_COOKIE_SECURE
=
True
REMEMBER_COOKIE_SECURE
=
True
APPKEY_LENGTH
=
8
DATA_DOWNLOAD_DIR
=
'data'
...
...
@@ -22,9 +23,11 @@ class DevelopmentConfig(Config):
DEBUG
=
True
SESSION_COOKIE_SECURE
=
False
REMEMBER_COOKIE_SECURE
=
False
class
TestingConfig
(
Config
):
TESTING
=
True
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