Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
talavis committed May 7, 2019
1 parent 360c9de commit db83b81
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions backend/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def post(self):
expires = datetime.today() + timedelta(days=30)

# Check if an sFTP user exists for the current user when the database is ready
passwd_hash = fn.digest(password, 'sha256')
passwd_hash = fn.encode(fn.digest(password, 'sha256'), 'hex')

try:
self.current_user.sftp_user.get()
Expand All @@ -649,19 +649,6 @@ def post(self):
account_expires = expires
).execute()

# The Postgres digest() function returns a string in the form "\xhash",
# leading to missmatch to hash when logging in.
# As fn.digest() won't be run until select() is run, the below code retrieves
# the "bad" hash and removes \x from the string
passwd_hash = (db.SFTPUser
.select()
.where(db.SFTPUser.user == self.current_user)
.get()).password_hash
(db.SFTPUser
.update(password_hash = passwd_hash.lstrip('\\x'))
.where(db.SFTPUser.user == self.current_user)
.execute())

self.finish({'user':username,
'expires':expires.strftime("%Y-%m-%d %H:%M"),
'password':password})
Expand Down

0 comments on commit db83b81

Please sign in to comment.