def validate_identity(self, user_name, password, visit_key): newuser = False user_name = to_db_encoding(user_name, self.user_class_db_encoding) try: user = User.by_user_name(user_name) except SQLObjectNotFound: log.info("Creating new user %s" % user_name) user = User(user_name=user_name) newuser = True if not self.validate_password(user, user_name, password): log.warning("Invalid password for %s" % user_name) if newuser: user.destroySelf() return None log.info("Login successful for %s" % user_name) try: link = VisitIdentity.by_visit_key(visit_key) link.user_id = user.id except SQLObjectNotFound: link = VisitIdentity(visit_key=visit_key, user_id=user.id) return SqlObjectIdentity(visit_key, user)
def main(): load_config() hub.begin() try: print "\nCreating guest user and giving it administrator priviliges" guest = User(user_name="guest", display_name="Bodhi Hacker", password="******") admin = Group(group_name="releng", display_name="Bodhi administrators") guest.addGroup(admin) hub.commit() except DuplicateEntryError: print "guest account already created"
def main(): load_config() hub.begin() try: print "\nCreating guest user and giving it administrator priviliges" guest = User(user_name='guest', display_name='Bodhi Hacker', password='******') admin = Group(group_name='releng', display_name='Bodhi administrators') guest.addGroup(admin) hub.commit() except DuplicateEntryError: print "guest account already created"