def __init__(self,*args,**kw): for k,v in kw.iteritems(): if hasattr(self,k): #print "setting", k, "with value", v if k == 'password': v = identity.encrypt_password(v) setattr(self,k,v)
def login(self, forward_url=None, previous_url=None, *args, **kw): print "logging in" if not identity.current.anonymous \ and identity.was_login_attempted() \ and not identity.get_identity_errors(): raise redirect(forward_url) session.begin() password = base64.encodestring(str(random.getrandbits(64))).strip() username = uuid.uuid1().hex user = User(user_name=username, display_name='Guest User', password=identity.encrypt_password(password)) session.commit() session.flush() identity.current_provider.validate_identity(username, password, identity.current.visit_key) raise redirect(request.path)
def update(self, id=None, **kw): """Save or create record to model""" #update kw log.info('kw: ' + str(kw)) log.info('kw: ' + str(kw)) log.info('kw: ' + str(kw)) log.info('kw: ' + str(kw)) log.info('kw: ' + str(kw)) try: if isinstance(kw['Bidder_groups'],list): groups = Group.select(Group.c.group_id.in_(*kw['Bidder_groups'])) else: groups = Group.select(Group.c.group_id.in_(kw['Bidder_groups'])) except: groups = [] #create if not id: kw['groups']=groups Bidder(**kw) flash("Bidder was successfully created.") raise redirect("list") #update else: record = Bidder.get_by(Bidder_id=int(id)) for attr in kw: if attr == 'password': setattr(record, attr, identity.encrypt_password(kw[attr])) else: setattr(record, attr, kw[attr]) record.groups = groups log.info("Saved update on Bidder " + record.Bidder_name + str(kw)) flash("Bidder was successfully updated.") raise redirect("../list")
def changePassword(self, **kw): user = User.get(int(cherrypy.session['current_user'])) print kw old = kw['old'] password = kw['new'] retype = kw['retype'] if identity.encrypt_password(old) != user.password: cherrypy.response.status = 412 return "Old password incorrect" if password != retype: cherrypy.response.status = 412 return "New password does not match retyped password" if password == '': cherrypy.response.status = 412 return "Password cannot be blank" user.password = password return "Password changed!"
def _set_password( self, cleartext_password ): "Runs cleartext_password through the hash algorithm before saving." hash = identity.encrypt_password(cleartext_password) self._SO_set_password(hash)
def _set_password(self, cleartext_password): "Runs cleartext_password through the hash algorithm before saving." password_hash = identity.encrypt_password(cleartext_password) self._SO_set_password(password_hash) #pylint: disable-msg=E1101
def _set_password(self, password): """ encrypts password on the fly using the encryption algo defined in the configuration """ self._password = identity.encrypt_password(password)
def _set_password(self, cleartext_password): """Runs cleartext_password through the hash algorithm before saving.""" password_hash = identity.encrypt_password(cleartext_password) self._SO_set_password(password_hash)
def _set_password(self, password): """Run cleartext password through the hash algorithm before saving.""" self._password = identity.encrypt_password(password)
def _set_password(self, cleartext_password): password_hash = identity.encrypt_password(cleartext_password) self._SO_set_password(password_hash)