+ # self.tokens_cache.clear() # not required any more
+
+ def remove_token_from_cache(self, token=None):
+ if token:
+ self.tokens_cache.pop(token, None)
+ else:
+ self.tokens_cache.clear()
+ self.msg.write("admin", "revoke_token", {"_id": token} if token else None)
+
+ def check_password_expiry(self, outdata):
+ """
+ This method will check for password expiry of the user
+ :param outdata: user token information
+ """
+ user_content = None
+ present_time = time()
+ user = outdata["username"]
+ if self.config["authentication"].get("pwd_expiry_check"):
+ user_content = self.db.get_list("users", {"username": user})[0]
+ if not user_content.get("username") == "admin":
+ user_content["_admin"]["modified_time"] = present_time
+ if user_content.get("_admin").get("expire_time"):
+ expire_time = user_content["_admin"]["expire_time"]
+ else:
+ expire_time = present_time
+ uid = user_content["_id"]
+ self.db.set_one("users", {"_id": uid}, user_content)
+ if not present_time < expire_time:
+ return True
+ else:
+ pass