Added some logging
This commit is contained in:
parent
7634069363
commit
dd3779ac6c
1 changed files with 6 additions and 3 deletions
|
@ -11,6 +11,7 @@ import crypt
|
||||||
|
|
||||||
from fas.model import People
|
from fas.model import People
|
||||||
from fas.model import PersonEmails
|
from fas.model import PersonEmails
|
||||||
|
from fas.model import Log
|
||||||
|
|
||||||
from fas.auth import *
|
from fas.auth import *
|
||||||
|
|
||||||
|
@ -98,7 +99,7 @@ class UserView(validators.Schema):
|
||||||
username = KnownUser
|
username = KnownUser
|
||||||
|
|
||||||
class UserEdit(validators.Schema):
|
class UserEdit(validators.Schema):
|
||||||
username = KnownUser
|
targetname = KnownUser
|
||||||
|
|
||||||
def generatePassword(password=None,length=14,salt=''):
|
def generatePassword(password=None,length=14,salt=''):
|
||||||
''' Generate Password '''
|
''' Generate Password '''
|
||||||
|
@ -295,15 +296,17 @@ class User(controllers.Controller):
|
||||||
username = turbogears.identity.current.user_name
|
username = turbogears.identity.current.user_name
|
||||||
person = People.by_username(username)
|
person = People.by_username(username)
|
||||||
|
|
||||||
# TODO: Auth method (complete with salted hash)
|
current_encrypted = generatePassword(currentpassword)
|
||||||
if not person.password == currentpassword:
|
if not person.password == current_encrypted['hash']:
|
||||||
turbogears.flash('Your current password did not match')
|
turbogears.flash('Your current password did not match')
|
||||||
return dict()
|
return dict()
|
||||||
newpass = generatePassword(password)
|
newpass = generatePassword(password)
|
||||||
try:
|
try:
|
||||||
person.password = newpass['hash']
|
person.password = newpass['hash']
|
||||||
|
Log(author_id=person.id, description='Password changed')
|
||||||
turbogears.flash(_("Your password has been changed."))
|
turbogears.flash(_("Your password has been changed."))
|
||||||
except:
|
except:
|
||||||
|
Log(author_id=person.id, description='Password change failed!')
|
||||||
turbogears.flash(_("Your password could not be changed."))
|
turbogears.flash(_("Your password could not be changed."))
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue