Esempio n. 1
0
    def post(self):
        msg = xmpp.Message(self.request.POST)
        logging.debug(self.request.body + "$" + str(msg))
        commands = [
            'status', 'help', 'update', 'home', 'shorten', 'remind', 'verify'
        ]
        msgSplit = msg.body.split(' ')

        self.user = GrafiteUser.getUser(username=self._getUserName(msg.sender))
        if self.user is None and msgSplit[0].lower() != "verify":
            msg.reply(STR_HELLO + "\n" + STR_PROMPT_REGISTER)
            return

        logging.debug("*CHAT*: " + self.user.key().name())
        #login the user!
        if self.user:
            res = GrafiteUser.login(self.user.key().name(), self.user.password,
                                    "XMPP")
            self.user.accessToken = res[1]
        elif msgSplit[0].lower() != 'verify':
            msg.reply(
                "Hey, I couldn't really identify who you are! :-( Please register yourself.."
            )
            return
        if msgSplit[0].lower() in commands:
            try:
                getattr(self, "cmd_" + msgSplit[0].lower())(msg)
            except Exception, e:
                msg.reply("Error!\n" + str(e))
                import traceback
                msg.reply(traceback.format_exc())
Esempio n. 2
0
 def post(self):
     msg = xmpp.Message(self.request.POST)
     logging.debug(self.request.body + "$" + str(msg))
     commands = ['status','help','update','home','shorten','remind','verify']
     msgSplit = msg.body.split(' ')
     
     self.user = GrafiteUser.getUser(username=self._getUserName(msg.sender))
     if self.user is None and msgSplit[0].lower() != "verify":
         msg.reply(STR_HELLO + "\n" + STR_PROMPT_REGISTER)
         return
     
     logging.debug("*CHAT*: " + self.user.key().name())
     #login the user!
     if self.user:
         res = GrafiteUser.login(self.user.key().name(), self.user.password, "XMPP")
         self.user.accessToken = res[1]
     elif msgSplit[0].lower() != 'verify':
         msg.reply("Hey, I couldn't really identify who you are! :-( Please register yourself..")
         return
     if msgSplit[0].lower() in commands:
         try:
             getattr(self,"cmd_" + msgSplit[0].lower())(msg)
         except Exception, e:
             msg.reply("Error!\n" + str(e))
             import traceback
             msg.reply(traceback.format_exc())
Esempio n. 3
0
 def getUserAccessToken(pac):
     res = PermanentAccessCodes.all().filter("accessToken =",pac)
     if res.count()!=1:
         return {"result":"error","message":"Invalid PAC"}
     res = res.fetch(1)[0]
     res, userAt,t = GrafiteUser.login(res.user.key().name(),res.user.password, res.app.appName)
     if res != "success":
         return {"result":"error","message":"Unable to login user!"}
     return {"result":"success","AccessToken":userAt}
Esempio n. 4
0
 def getUserAccessToken(pac):
     res = PermanentAccessCodes.all().filter("accessToken =", pac)
     if res.count() != 1:
         return {"result": "error", "message": "Invalid PAC"}
     res = res.fetch(1)[0]
     res, userAt, t = GrafiteUser.login(res.user.key().name(),
                                        res.user.password, res.app.appName)
     if res != "success":
         return {"result": "error", "message": "Unable to login user!"}
     return {"result": "success", "AccessToken": userAt}
Esempio n. 5
0
    def post_pinged(self,usr):
        res = GrafiteUser.all().filter("emailId =",usr.emailId)
        if res.count()!=1:
            return {"result":"error","message":"EmailId not found!"}
        
        user = res.fetch(1)[0]
        res1,at, expire = GrafiteUser.login(user.key().name(), user.password, "Web-browser")
        if res1!="success":
            return {"result":"error","message":"Unable to login"}

        self.response.headers.add_header('Set-Cookie',UserService.makeCookieString(
            expire.strftime(time_format),{"access_token":at}))
                
        return {"result":"success","value":res.count()==1}