Browse Source

La plantilla funcionando con usuario

politica
Celestino Rey 1 year ago
parent
commit
0d71b04617
16 changed files with 57 additions and 20 deletions
  1. BIN
      ReymotaPy/._.DS_Store
  2. BIN
      ReymotaPy/servicios/._.DS_Store
  3. BIN
      ReymotaPy/servicios/instance/reymotapy.db
  4. BIN
      ReymotaPy/servicios/reymotapy/._.DS_Store
  5. +3
    -0
      ReymotaPy/servicios/reymotapy/auth.py
  6. +3
    -0
      ReymotaPy/servicios/reymotapy/paginas.py
  7. BIN
      ReymotaPy/servicios/reymotapy/static/._.DS_Store
  8. +1
    -1
      ReymotaPy/servicios/reymotapy/static/css/portal.css
  9. BIN
      ReymotaPy/servicios/reymotapy/static/images/._.DS_Store
  10. BIN
      ReymotaPy/servicios/reymotapy/static/images/background/._background-1.jpg
  11. BIN
      ReymotaPy/servicios/reymotapy/static/images/background/._background-palmeras.jpg
  12. BIN
      ReymotaPy/servicios/reymotapy/static/images/background/background-palmeras.jpg
  13. +3
    -1
      ReymotaPy/servicios/reymotapy/templates/.gitignore
  14. +11
    -2
      ReymotaPy/servicios/reymotapy/templates/_cabecera.html
  15. +17
    -8
      ReymotaPy/servicios/reymotapy/templates/login.html
  16. +19
    -8
      ReymotaPy/servicios/reymotapy/templates/signup.html

BIN
ReymotaPy/._.DS_Store View File


BIN
ReymotaPy/servicios/._.DS_Store View File


BIN
ReymotaPy/servicios/instance/reymotapy.db View File


BIN
ReymotaPy/servicios/reymotapy/._.DS_Store View File


+ 3
- 0
ReymotaPy/servicios/reymotapy/auth.py View File

@ -13,12 +13,14 @@ def login():
@bp.route('/login', methods=['POST'])
def login_post():
print("Entrando en sesión (o no)")
username = request.form.get('username')
password = request.form.get('password')
remember = True if request.form.get('remember') else False
user = User.query.filter_by(username=username).first()
print("Usuario: "+user.username)
# check if the user actually exists
# take the user-supplied password, hash it, and compare it to the hashed password in the database
if not user or not check_password_hash(user.password, password):
@ -36,6 +38,7 @@ def signup():
@bp.route('/signup', methods=['POST'])
def signup_post():
print("Creando usuario")
username = request.form.get('username')
password = request.form.get('password')


+ 3
- 0
ReymotaPy/servicios/reymotapy/paginas.py View File

@ -25,10 +25,12 @@ def notifications():
return render_template('notifications.html')
@bp.route('/account')
@login_required
def account():
return render_template('account.html')
@bp.route('/settings')
@login_required
def settings():
return render_template('settings.html')
@ -49,6 +51,7 @@ def cuatrocerocuatro():
return render_template('404.html')
@bp.route('/charts')
@login_required
def charts():
return render_template('charts.html')


BIN
ReymotaPy/servicios/reymotapy/static/._.DS_Store View File


+ 1
- 1
ReymotaPy/servicios/reymotapy/static/css/portal.css
File diff suppressed because it is too large
View File


BIN
ReymotaPy/servicios/reymotapy/static/images/._.DS_Store View File


BIN
ReymotaPy/servicios/reymotapy/static/images/background/._background-1.jpg View File


BIN
ReymotaPy/servicios/reymotapy/static/images/background/._background-palmeras.jpg View File


BIN
ReymotaPy/servicios/reymotapy/static/images/background/background-palmeras.jpg View File

Before After
Width: 1000  |  Height: 1139  |  Size: 360 KiB

+ 3
- 1
ReymotaPy/servicios/reymotapy/templates/.gitignore View File

@ -1,2 +1,4 @@
.DS_Store
config.codekit3
config.codekit3
.venv
venv

+ 11
- 2
ReymotaPy/servicios/reymotapy/templates/_cabecera.html View File

@ -117,16 +117,25 @@
</svg>
</a>
</div><!--//app-utility-item-->
<div class="app-utility-item app-user-dropdown dropdown">
{% if current_user.is_authenticated %}
<a class="dropdown-toggle" id="user-dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"><img src="{{ url_for('static', filename='images/user.png') }}" alt="user profile"></a>
{% else %}
<a class="dropdown-toggle" id="user-dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"><img src="{{ url_for('static', filename='images/app-logo.svg') }}" alt="user profile"></a>
{% endif %}
<ul class="dropdown-menu" aria-labelledby="user-dropdown-toggle">
{% if current_user.is_authenticated %}
<li><a class="dropdown-item" href="{{ url_for('paginas.account') }}">Account</a></li>
<li><a class="dropdown-item" href="{{ url_for('paginas.settings') }}">Settings</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="{{ url_for('paginas.login') }}">Log Out</a></li>
<li><a class="dropdown-item" href="{{ url_for('auth.logout') }}">Log Out</a></li>
{% else %}
<li><a class="dropdown-item" href="{{ url_for('auth.login') }}">Login</a></li>
{% endif %}
</ul>
</div><!--//app-user-dropdown-->
</div><!--//app-utilities-->
</div><!--//row-->
</div><!--//app-header-content-->


+ 17
- 8
ReymotaPy/servicios/reymotapy/templates/login.html View File

@ -8,14 +8,21 @@
{% include("_branding.html") %}
<h2 class="auth-heading text-center mb-5">Log in to Portal</h2>
<div class="auth-form-container text-start">
<form class="auth-form login-form">
<div class="email mb-3">
<label class="sr-only" for="signin-email">Email</label>
<input id="signin-email" name="signin-email" type="email" class="form-control signin-email" placeholder="Email address" required="required">
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="notification is-danger">
{{ messages[0] }}
</div>
{% endif %}
{% endwith %}
<form class="auth-form login-form" method="POST" action="/login">
<div class="text mb-3">
<label class="sr-only" for="signin-name">Nombre de usuario</label>
<input id="signin-name" name="username" type="text" class="form-control signin-name" placeholder="Usuario" required="required">
</div><!--//form-group-->
<div class="password mb-3">
<label class="sr-only" for="signin-password">Password</label>
<input id="signin-password" name="signin-password" type="password" class="form-control signin-password" placeholder="Password" required="required">
<input id="signin-password" name="password" type="password" class="form-control signin-password" placeholder="Password" required="required">
<div class="extra mt-3 row justify-content-between">
<div class="col-6">
<div class="form-check">
@ -25,11 +32,13 @@
</label>
</div>
</div><!--//col-6-->
<!--
<div class="col-6">
<div class="forgot-password text-end">
<a href="reset-password.html">Forgot password?</a>
<a href="{{ url_for('paginas.resetpassword') }}">Forgot password?</a>
</div>
</div><!--//col-6-->
</div>
-->
</div><!--//extra-->
</div><!--//form-group-->
<div class="text-center">
@ -37,7 +46,7 @@
</div>
</form>
<div class="auth-option text-center pt-5">No Account? Sign up <a class="text-link" href="signup.html" >here</a>.</div>
<div class="auth-option text-center pt-5">No Account? Sign up <a class="text-link" href="{{ url_for('auth.signup') }}" >here</a>.</div>
</div><!--//auth-form-container-->
</div><!--//auth-body-->


+ 19
- 8
ReymotaPy/servicios/reymotapy/templates/signup.html View File

@ -9,18 +9,29 @@
<h2 class="auth-heading text-center mb-4">Sign up to Portal</h2>
<div class="auth-form-container text-start mx-auto">
<form class="auth-form auth-signup-form">
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="notification is-danger">
{{ messages[0] }}. Go to <a href="{{ url_for('auth.login') }}">login page</a>.
</div>
{% endif %}
{% endwith %}
<form class="auth-form auth-signup-form" method="POST" action="/signup">
<div class="email mb-3">
<label class="sr-only" for="signup-email">Your Name</label>
<input id="signup-name" name="signup-name" type="text" class="form-control signup-name" placeholder="Full name" required="required">
<label class="sr-only" for="signup-name">Your Name</label>
<input id="signup-name" name="username" type="text" class="form-control signup-name" placeholder="Nombre de usuario" required="required">
</div>
<!--
<div class="email mb-3">
<label class="sr-only" for="signup-email">Your Email</label>
<input id="signup-email" name="signup-email" type="email" class="form-control signup-email" placeholder="Email" required="required">
<label class="sr-only" for="email">Your Email</label>
<input id="signup-email" name="email" type="email" class="form-control signup-email" placeholder="Email" required="required">
</div>
-->
<div class="password mb-3">
<label class="sr-only" for="signup-password">Password</label>
<input id="signup-password" name="signup-password" type="password" class="form-control signup-password" placeholder="Create a password" required="required">
<label class="sr-only" for="password">Password</label>
<input id="signup-password" name="password" type="password" class="form-control signup-password" placeholder="Create a password" required="required">
</div>
<div class="extra mb-3">
<div class="form-check">
@ -36,7 +47,7 @@
</div>
</form><!--//auth-form-->
<div class="auth-option text-center pt-5">Already have an account? <a class="text-link" href="login.html" >Log in</a></div>
<div class="auth-option text-center pt-5">Already have an account? <a class="text-link" href="{{ url_for('auth.login') }}" >Log in</a></div>
</div><!--//auth-form-container-->


Loading…
Cancel
Save