initial implementation on reset password url

This commit is contained in:
Leticia Portella 2018-09-25 01:12:43 -03:00
parent a61f7102d5
commit fdb3608ddb

View file

@ -7,14 +7,25 @@ locally in a dbm file, and checked next time they log in.
""" """
import dbm import dbm
from jupyterhub.auth import Authenticator from jupyterhub.auth import Authenticator
from jupyterhub.handlers import BaseHandler
from jupyterhub.orm import User from jupyterhub.orm import User
from tornado import gen from tornado import gen, web
from traitlets.traitlets import Unicode, Bool from traitlets.traitlets import Unicode, Bool
import bcrypt import bcrypt
class ResetPasswordHandler(BaseHandler):
"""Render the reset password page."""
@web.authenticated
async def get(self):
html = self.render_template('reset.html')
self.finish(html)
class FirstUseAuthenticator(Authenticator): class FirstUseAuthenticator(Authenticator):
""" """
JupyterHub authenticator that lets users set password on first use. JupyterHub authenticator that lets users set password on first use.
@ -74,3 +85,12 @@ class FirstUseAuthenticator(Authenticator):
""" """
with dbm.open(self.dbm_path, 'c', 0o600) as db: with dbm.open(self.dbm_path, 'c', 0o600) as db:
del db[user.name] del db[user.name]
def reset_password(self, data):
username = data['username']
new_password = data['password']
db[username] = bcrypt.hashpw(new_password.encode(), bcrypt.gensalt())
return username
def get_handlers(self, app):
return super().get_handlers(app) + [(r'/auth/change-password', ResetPasswordHandler)]