zmiana obslugi haseł, docker/podman
This commit is contained in:
10
app.py
10
app.py
@@ -27,7 +27,7 @@ from flask import (
|
||||
url_for, session, flash, send_file
|
||||
)
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from passlib.hash import bcrypt
|
||||
from passlib.context import CryptContext
|
||||
#from flask_wtf.csrf import CSRFProtect
|
||||
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
@@ -56,14 +56,18 @@ os.makedirs(DATA_DIR, exist_ok=True)
|
||||
###############################################################################
|
||||
# Modele bazy danych
|
||||
###############################################################################
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
class User(db.Model):
|
||||
__tablename__ = 'users'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
username = db.Column(db.String(120), unique=True, nullable=False)
|
||||
password_hash = db.Column(db.String(255), nullable=False)
|
||||
|
||||
def set_password(self, password):
|
||||
self.password_hash = pwd_context.hash(password)
|
||||
|
||||
def check_password(self, password):
|
||||
return bcrypt.verify(password, self.password_hash)
|
||||
return pwd_context.verify(password, self.password_hash)
|
||||
|
||||
class Router(db.Model):
|
||||
__tablename__ = 'routers'
|
||||
@@ -1345,7 +1349,7 @@ def change_password():
|
||||
flash("Nowe hasło i potwierdzenie nie są zgodne.")
|
||||
return redirect(url_for('change_password'))
|
||||
|
||||
user.password_hash = bcrypt.hash(new_password)
|
||||
user.password_hash = pwd_context.hash(new_password)
|
||||
db.session.commit()
|
||||
flash("Hasło zostało zmienione pomyślnie.")
|
||||
return redirect(url_for('dashboard'))
|
||||
|
Reference in New Issue
Block a user