def adduser(username,itcode,department,team,email,role): user = User(name = username, role = role, itcode = itcode, department = department, team = team, email = email, password = md5(default_user_password)) session.add(user) session.flush() session.commit()
def login(itcode,password): query = session.query(User) user = query.filter_by(itcode = itcode).first() if user : db_password = user.password if md5(password) == db_password: return True,user else: return False,user else: return False