MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / route

Method route

plugins/disabled-UiPassword/UiPasswordPlugin.py:33–47  ·  view source on GitHub ↗
(self, path)

Source from the content-addressed store, hash-verified

31 last_cleanup = time.time()
32
33 def route(self, path):
34 # Restict Ui access by ip
35 if config.ui_restrict and self.env['REMOTE_ADDR'] not in config.ui_restrict:
36 return self.error403(details=False)
37 if path.endswith("favicon.ico"):
38 return self.actionFile("src/Ui/media/img/favicon.ico")
39 else:
40 if config.ui_password:
41 if time.time() - self.last_cleanup > 60 * 60: # Cleanup expired sessions every hour
42 self.cleanup()
43 # Validate session
44 session_id = self.getCookies().get("session_id")
45 if session_id not in self.sessions: # Invalid session id, display login
46 return self.actionLogin()
47 return super(UiRequestPlugin, self).route(path)
48
49 # Action: Login
50 @helper.encodeResponse

Callers

nothing calls this directly

Calls 6

actionFileMethod · 0.95
cleanupMethod · 0.95
actionLoginMethod · 0.95
error403Method · 0.80
getCookiesMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected