本文整理汇总了Python中authentication.Authentication.is_logged_in方法的典型用法代码示例。如果您正苦于以下问题:Python Authentication.is_logged_in方法的具体用法?Python Authentication.is_logged_in怎么用?Python Authentication.is_logged_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类authentication.Authentication
的用法示例。
在下文中一共展示了Authentication.is_logged_in方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import is_logged_in [as 别名]
class LoginData:
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
if self.authentication.is_logged_in():
if self.authentication.is_admin():
responseMsg = self.authentication.get_name() + ":admin"
else:
responseMsg = self.authentication.get_name() + ":notadmin"
else:
responseMsg = self.authentication.get_error()
response.setStatus(500)
writer = response.getPrintWriter("text/html; charset=UTF-8")
writer.println(responseMsg)
writer.close()
示例2: __init__
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import is_logged_in [as 别名]
class DeleteData:
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 process(self):
record = formData.get("record")
try:
Services.storage.removeObject(record)
Services.indexer.remove(record)
self.writer.println(record)
self.writer.close()
except Exception, e:
self.throw_error("Error deleting object: " + e.getMessage())
示例3: __init__
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import is_logged_in [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:
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import is_logged_in [as 别名]
class SettingsActions:
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:
print " * settings.py : AJAX : Unauthorised access"
self.throw_error("Only administrative users can access this feature")
def getWatcherFile(self):
configFile = FascinatorHome.getPathFile("watcher/config.json")
if configFile.exists():
return JsonConfigHelper(configFile)
return None
def process(self):
print " * settings.py: formData=%s" % formData
result = "{}"
portalManager = Services.getPortalManager()
portal = portalManager.get(portalId)
func = formData.get("func")
if func == "view-update":
portal.setDescription(formData.get("view-description"))
portal.setQuery(formData.get("view-query"))
portal.setSearchQuery(formData.get("view-search-query"))
print " *** ", formData.get("view-records-per-page")
portal.setRecordsPerPage(int(formData.get("view-records-per-page")))
portal.setFacetCount(int(formData.get("view-facet-count")))
portal.setFacetSort(formData.get("view-facet-sort") is not None)
portalManager.save(portal)
elif func == "general-update":
config = JsonConfig()
email = StringUtils.trimToEmpty(formData.get("general-email"))
systemEmail = StringUtils.trimToEmpty(config.get("email"))
print email, systemEmail
if systemEmail != email:
config.set("email", formData.get("general-email"), True)
config.set("configured", "true", True)
config.store(NullWriter(), True)
# mark restart
Services.getHouseKeepingManager().requestUrgentRestart()
else:
print " * settings.py: email not updated: did not change"
self.throw_error("Email address is the same! No change saved.")
elif func == "facets-update":
portal.removePath("portal/facet-fields")
fields = formData.getValues("field")
labels = formData.getValues("label")
displays = formData.getValues("display")
deletes = formData.getValues("delete")
for i in range(0, len(fields)):
field = fields[i]
if deletes[i] == "false":
portal.set("portal/facet-fields/%s/label" % field, labels[i])
portal.set("portal/facet-fields/%s/display" % field, displays[i])
portalManager.save(portal)
elif func == "backup-update":
pathIds = formData.get("pathIds").split(",")
actives = formData.getValues("backup-active")
deletes = formData.getValues("backup-delete")
if actives is None:
actives = []
# renditions = formData.getValues("backup-rendition")
# if renditions is None:
# renditions = []
queries = formData.getValues("backup-queries")
if queries is None:
queries = []
paths = HashMap()
for pathId in pathIds:
if deletes is None or pathId not in deletes:
path = formData.get("%s-path" % pathId)
pathName = path.replace("/", "_").replace("${user.home}", "")
active = str(pathId in actives).lower()
# rendition = str(pathId in renditions).lower()
query = str(pathId in queries).lower()
ignoreFilter = formData.get("%s-ignore" % pathId)
json = HashMap()
json.put("path", path)
json.put("active", active)
json.put("include-portal-query", query)
json.put("ignoreFilter", ignoreFilter)
storage = HashMap()
storage.put("type", "file-system")
filesystem = HashMap()
filesystem.put("home", path)
filesystem.put("use-link", "false")
storage.put("file-system", filesystem)
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import is_logged_in [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")
#.........这里部分代码省略.........