def check(): # replace with actual check if <username> is in <groupname> user = BMTObjects.get_user_by_login(cherrypy.request.login) user.read() c = False if groupname in user.list_access_groups: c = True return c
def check_credentials(username, password): """Verifies credentials for username and password. Returns None on success or a string describing the error on failure""" # Adapt to your needs #if username in ('joe', 'steve') and password == 'secret': # return None #else: # return u"Incorrect username or password." user = BMTObjects.get_user_by_login(username) user.read() if user is None: return u"Username %s is unknown to me." % username elif user.password != password: BMTObjects.add_to_log("Указан неверный пароль для пользователя %s." % username, "w") return u"Incorrect password" elif user.disabled != 0: BMTObjects.add_to_log("Пользователь %s отключен." % username, "w") return u"User disabled." else: return None
def check_credentials(username, password): """Verifies credentials for username and password. Returns None on success or a string describing the error on failure""" # Adapt to your needs #if username in ('joe', 'steve') and password == 'secret': # return None #else: # return u"Incorrect username or password." user = BMTObjects.get_user_by_login(username) user.read() if user is None: return u"Username %s is unknown to me." % username elif user.password != password: BMTObjects.add_to_log( "Указан неверный пароль для пользователя %s." % username, "w") return u"Incorrect password" elif user.disabled != 0: BMTObjects.add_to_log("Пользователь %s отключен." % username, "w") return u"User disabled." else: return None