예제 #1
0
 def processLoginAction(self):
     data = parse_qs(self.get_body().decode("utf-8"))
     data = {k: v[0] for k, v in data.items()}
     userlist = UserList.getSharedInstance()
     if "user" in data and "password" in data:
         if data["user"] in userlist:
             user = userlist[data["user"]]
             if user.password.is_valid(data["password"]):
                 # TODO evaluate password force_change and redirect to password change
                 key = SessionStorage.getSharedInstance().startSession(
                     {"user": user.name})
                 cookie = SimpleCookie()
                 cookie["owrx-session"] = key
                 target = self.request.query["ref"][
                     0] if "ref" in self.request.query else "/settings"
                 self.send_redirect(target, cookies=cookie)
                 return
     self.send_redirect("/login")
예제 #2
0
파일: admin.py 프로젝트: jketterl/openwebrx
 def getUser(self, request):
     if "owrx-session" not in request.cookies:
         return None
     session_id = request.cookies["owrx-session"].value
     storage = SessionStorage.getSharedInstance()
     session = storage.getSession(session_id)
     if session is None:
         return None
     if "user" not in session:
         return None
     userList = UserList.getSharedInstance()
     user = None
     try:
         user = userList[session["user"]]
         storage.prolongSession(session_id)
     except KeyError:
         pass
     return user
예제 #3
0
 def processLoginAction(self):
     data = parse_qs(self.get_body().decode("utf-8"))
     data = {k: v[0] for k, v in data.items()}
     userlist = UserList.getSharedInstance()
     if "user" in data and "password" in data:
         if data["user"] in userlist:
             user = userlist[data["user"]]
             if user.is_enabled() and user.password.is_valid(data["password"]):
                 key = SessionStorage.getSharedInstance().startSession({"user": user.name})
                 cookie = SimpleCookie()
                 cookie["owrx-session"] = key
                 target = self.request.query["ref"][0] if "ref" in self.request.query else "/settings"
                 if user.must_change_password:
                     target = "/pwchange?{0}".format(urlencode({"ref": target}))
                 self.set_response_cookies(cookie)
                 self.send_redirect(target)
                 return
     target = "{}login?{}".format(self.get_document_root(), urlencode({"ref": self.request.query["ref"][0]}))
     self.send_redirect(target)