Exemplo n.º 1
0
    def logout_session(self):
        """Delete user's current session and cookie"""
        # Delete the session from Redis
        try:
            if self.session_id:
                SessionCache.delete_session(self.id, self.session_id)
        except:
            current_app.logger.warning("User without session_id")

        # If there is a cookie, try deleting the session in redis
        cookie_data = request.cookies.get(
            current_app.config.get("REMEMBER_COOKIE_NAME"))
        if cookie_data:
            s = Serializer(current_app.config["SECRET_KEY"])
            try:
                data = s.loads(cookie_data)
                user_id = data["user_id"]
                session_id = data["session_id"]
            except:
                current_app.logger.info("Corrupt cookie for user %s" % self.id)
                return

            if user_id and session_id:
                SessionCache.delete_session(user_id, session_id)
                current_app.logger.debug("Deleted cookie session %s" %
                                         session_id)
Exemplo n.º 2
0
 def logout_target_session(self, session_id):
     """Delete user's current session and cookie"""
     SessionCache.delete_session(self.id, session_id)