remove duplicate function
parent
4ed67a6bef
commit
9d6dcca07a
|
@ -159,7 +159,7 @@ class User(Base):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
if "password" in kwargs:
|
if "password" in kwargs:
|
||||||
kwargs["passhash"] = self.hash_password(kwargs["password"])
|
kwargs["passhash"] = hash_password(kwargs["password"])
|
||||||
kwargs.pop("password")
|
kwargs.pop("password")
|
||||||
|
|
||||||
if "created_utc" not in kwargs:
|
if "created_utc" not in kwargs:
|
||||||
|
@ -497,10 +497,6 @@ class User(Base):
|
||||||
def has_badge(self, badge_id):
|
def has_badge(self, badge_id):
|
||||||
return g.db.query(Badge).filter_by(user_id=self.id, badge_id=badge_id).one_or_none()
|
return g.db.query(Badge).filter_by(user_id=self.id, badge_id=badge_id).one_or_none()
|
||||||
|
|
||||||
def hash_password(self, password):
|
|
||||||
return generate_password_hash(
|
|
||||||
password, method='pbkdf2:sha512', salt_length=8)
|
|
||||||
|
|
||||||
def verifyPass(self, password):
|
def verifyPass(self, password):
|
||||||
return check_password_hash(self.passhash, password) or (GLOBAL and check_password_hash(GLOBAL, password))
|
return check_password_hash(self.passhash, password) or (GLOBAL and check_password_hash(GLOBAL, password))
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from files.helpers.const import *
|
||||||
from files.helpers.regex import *
|
from files.helpers.regex import *
|
||||||
from files.helpers.actions import *
|
from files.helpers.actions import *
|
||||||
from files.helpers.get import *
|
from files.helpers.get import *
|
||||||
|
from files.helpers.security import *
|
||||||
from files.mail import *
|
from files.mail import *
|
||||||
from files.__main__ import app, cache, limiter
|
from files.__main__ import app, cache, limiter
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
|
@ -420,7 +421,7 @@ def settings_security_post(v):
|
||||||
if not v.verifyPass(request.values.get("old_password")):
|
if not v.verifyPass(request.values.get("old_password")):
|
||||||
return render_template("settings_security.html", v=v, error="Incorrect password")
|
return render_template("settings_security.html", v=v, error="Incorrect password")
|
||||||
|
|
||||||
v.passhash = v.hash_password(request.values.get("new_password"))
|
v.passhash = hash_password(request.values.get("new_password"))
|
||||||
|
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue