Exemplo n.º 1
0
    def post(self):

        # Step 1, Login with default account
        argObj = getArgObj(self.request)
        paras = {
            "account": self.get_argument("username"),
            "password": self.get_argument("password"),
            "role": 7,
        }
        argObj["api"] = "octlink.tundra.v1.account.APILoginByAccount"
        argObj["paras"] = paras

        self.db = dbmysql.mysqldb()
        session = getSessionObj(self.db,
                                sessionId="00000000000000000000000000000000")
        del self.db

        argObj["session"] = session
        retObj = doDispatching(argObj, session, API_PROTOS)
        if retObj["RetCode"] != OCT_SUCCESS:
            ERROR("login error %s" % str(retObj))
            self.redirect("/login/?error=true")
        else:
            sessionObj = retObj["RetObj"]["session"]
            self.set_cookie("rvmusercookie", sessionObj["id"])
            self.set_cookie("username", retObj["RetObj"]["name"])
            self.set_cookie("userid", retObj["RetObj"]["id"])
            self.redirect("/")
Exemplo n.º 2
0
    def checkSession(self, argObj):
        apiName = argObj.get("api")

        if (apiName.split(".")[-1] in IGNORE_SESSION_APIS):
            DEBUG("User login API, no need check session")
            return (True, {})

        sessionId = getSessionId(argObj)
        if (not sessionId):
            return (False, {})

        DEBUG("got session id %s" % sessionId)

        sessionObj = getSessionObj(self.db, sessionId)
        if not sessionObj:
            return (False, {})

        return (True, sessionObj)
Exemplo n.º 3
0
    def get(self):

        cookie = self.get_cookie("rvmusercookie", "")
        username = self.get_cookie("username", "")
        userid = self.get_cookie("userid", "")
        accountname = self.get_cookie("accountname", "admin")

        if not cookie:
            self.redirect("/login/")
            return

        self.db = dbmysql.mysqldb()
        session = getSessionObj(self.db, sessionId=cookie)
        del self.db
        if not session:
            self.redirect("/login/")
            return

        self.render("userportal/userportal.html",
                    USER_NAME=username,
                    USER_ID=userid,
                    ACCOUNT_NAME=accountname,
                    SESSION_ID=session["id"])