change handler to user get_body_argument
This commit is contained in:
parent
64c4f7b886
commit
12a652976a
1 changed files with 3 additions and 9 deletions
|
@ -48,12 +48,9 @@ class ResetPasswordHandler(BaseHandler):
|
||||||
|
|
||||||
@web.authenticated
|
@web.authenticated
|
||||||
async def post(self):
|
async def post(self):
|
||||||
data = {}
|
|
||||||
for arg in self.request.arguments:
|
|
||||||
data[arg] = self.get_argument(arg, strip=False)
|
|
||||||
user = self.get_current_user()
|
user = self.get_current_user()
|
||||||
data['username'] = user.name
|
new_password = self.get_body_argument('password', strip=False)
|
||||||
self.authenticator.reset_password(data)
|
self.authenticator.reset_password(user.name, new_password)
|
||||||
|
|
||||||
html = self.render_template(
|
html = self.render_template(
|
||||||
'reset.html',
|
'reset.html',
|
||||||
|
@ -124,13 +121,10 @@ 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):
|
def reset_password(self, username, new_password):
|
||||||
"""
|
"""
|
||||||
This allow to change password of a logged user.
|
This allow to change password of a logged user.
|
||||||
"""
|
"""
|
||||||
username = data['username']
|
|
||||||
new_password = data['password']
|
|
||||||
|
|
||||||
with dbm.open(self.dbm_path, 'c', 0o600) as db:
|
with dbm.open(self.dbm_path, 'c', 0o600) as db:
|
||||||
db[username] = bcrypt.hashpw(new_password.encode(),
|
db[username] = bcrypt.hashpw(new_password.encode(),
|
||||||
bcrypt.gensalt())
|
bcrypt.gensalt())
|
||||||
|
|
Loading…
Add table
Reference in a new issue