本文整理汇总了Python中authentication.Authentication.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python Authentication.create_user方法的具体用法?Python Authentication.create_user怎么用?Python Authentication.create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类authentication.Authentication
的用法示例。
在下文中一共展示了Authentication.create_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Application
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import create_user [as 别名]
class Application(tornado.web.Application):
def __init__(self):
settings = dict(
autoreload=False,
compiled_template_cache=False,
static_hash_cache=False,
serve_traceback=True,
gzip=True,
template_path=os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')),
static_path=os.path.abspath(os.path.join(os.path.dirname(__file__), 'static')),
login_url='/login'
)
handlers = [
url(r'/', Domains, name="Domains", kwargs={'title': 'Domains'}),
url('/mailboxes', Mailboxes, name="Mailboxes", kwargs={'title': 'Mailboxes'}),
url('/login', Login, name="Login", kwargs={'title': "Login"}),
url('/logout', Logout, name="Logout"),
url('/set_language', SetLanguage, name="SetLanguage"),
url('/aliases', Aliases, name="Aliases", kwargs={'title': 'Aliases'}),
url('/profile', Profile, name="Profile", kwargs={'title': 'Profile'})
]
self.logger = logging.getLogger("application")
logging.basicConfig(level=logging.DEBUG)
self.app_settings = Settings
self.database = Database(self.app_settings.Database.DatabaseName, {'user': self.app_settings.Database.Username,
'passwd': self.app_settings.Database.Password,
'host': self.app_settings.Database.Address,
'port': self.app_settings.Database.Port})
self.authentication = Authentication(self)
tornado.locale.load_translations(os.path.join(os.path.dirname(__file__), Settings.Language.TranslationFolder))
tornado.locale.set_default_locale(Settings.Language.DefaultLanguage)
if not self.database.is_populated():
self.database.initialise()
self.authentication.create_user("admin", "admin")
tornado.web.Application.__init__(self, handlers, **settings)
示例2: __init__
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import create_user [as 别名]
class LoginData:
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
self.writer = response.getPrintWriter("text/html; charset=UTF-8")
if self.authentication.is_logged_in() and self.authentication.is_admin():
self.process()
else:
self.throw_error("Only administrative users can access this feature")
def add_user(self):
username = formData.get("field")
rolename = formData.get("hidden")
source = formData.get("source")
self.authentication.set_role_plugin(source)
self.authentication.set_role(username, rolename)
err = self.authentication.get_error()
if err is None:
self.writer.println(username)
self.writer.close()
else:
self.throw_error(err)
def change_password(self):
username = formData.get("username")
password = formData.get("password")
password_confirm = formData.get("password_confirm")
if password != password_confirm:
self.throw_error("The confirm password field does not match the password.")
else:
source = formData.get("source")
self.authentication.set_auth_plugin(source)
self.authentication.change_password(username, password)
err = self.authentication.get_error()
if err is None:
self.writer.println(username)
self.writer.close()
else:
self.throw_error(err)
def confirm_message(self):
msgId = formData.get("message")
hk = Services.getHouseKeepingManager()
if msgId is None:
self.throw_error("No message ID provided")
try:
if msgId == "ALL":
list = hk.getUserMessages();
for entry in list:
if not entry.block:
hk.confirmMessage(str(entry.id));
else:
hk.confirmMessage(msgId);
except:
error = sys.exc_info()[1]
self.throw_error(error.getMessage())
self.writer.println("ok")
self.writer.close()
def create_role(self):
rolename = formData.get("field")
source = formData.get("source")
self.authentication.set_role_plugin(source)
self.authentication.create_role(rolename)
err = self.authentication.get_error()
if err is None:
self.writer.println(rolename)
self.writer.close()
else:
self.throw_error(err)
def create_user(self):
username = formData.get("username")
password = formData.get("password")
password_confirm = formData.get("password_confirm")
if password != password_confirm:
self.throw_error("The confirm password field does not match the password.")
else:
source = formData.get("source")
self.authentication.set_auth_plugin(source)
self.authentication.create_user(username, password)
err = self.authentication.get_error()
if err is None:
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import create_user [as 别名]
class LoginData:
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
self.writer = response.getPrintWriter("text/html")
if self.authentication.is_logged_in() and self.authentication.is_admin():
self.process()
else:
self.throw_error("Only administrative users can access this feature")
def add_user(self):
username = formData.get("field")
rolename = formData.get("hidden")
source = formData.get("source")
self.authentication.set_role_plugin(source)
self.authentication.set_role(username, rolename)
err = self.authentication.get_error()
if err is None:
self.writer.println(username)
self.writer.close()
else:
self.throw_error(err)
def change_password(self):
username = formData.get("username")
password = formData.get("password")
password_confirm = formData.get("password_confirm")
if password != password_confirm:
self.throw_error("The confirm password field does not match the password.")
else:
source = formData.get("source")
self.authentication.set_auth_plugin(source)
self.authentication.change_password(username, password)
err = self.authentication.get_error()
if err is None:
self.writer.println(username)
self.writer.close()
else:
self.throw_error(err)
def create_role(self):
rolename = formData.get("field")
source = formData.get("source")
self.authentication.set_role_plugin(source)
self.authentication.create_role(rolename)
err = self.authentication.get_error()
if err is None:
self.writer.println(rolename)
self.writer.close()
else:
self.throw_error(err)
def create_user(self):
username = formData.get("username")
password = formData.get("password")
password_confirm = formData.get("password_confirm")
if password != password_confirm:
self.throw_error("The confirm password field does not match the password.")
else:
source = formData.get("source")
self.authentication.set_auth_plugin(source)
self.authentication.create_user(username, password)
err = self.authentication.get_error()
if err is None:
self.writer.println(username)
self.writer.close()
else:
self.throw_error(err)
def delete_role(self):
rolename = formData.get("rolename")
source = formData.get("source")
self.authentication.set_role_plugin(source)
self.authentication.delete_role(rolename)
err = self.authentication.get_error()
if err is None:
self.writer.println(rolename)
self.writer.close()
else:
self.throw_error(err)
def delete_user(self):
username = formData.get("username")
#.........这里部分代码省略.........