示例#1
0
    def login(self, logindata):
       
        (cardid, passwd) = parser.parseRetLoginXML(logindata)
        responseCode = 'responseCode'
        response = {responseCode: onlot.SUCCESS} #reponseCode for success
     
        
        # This is a web request. Check for existing sessions for the user                        
        rs = my.proc("proc_ssl_retailer_login('%s', '%s')" % (cardid, passwd))
        
        if rs.recordcount > 0:            
            result = int(rs.Fields['result'])            
          
            if result == 1: # SUCCESS result from database operation.
                response['balance'] = float(rs.Fields['balance'])
##                sessionid = rs.Fields['sid'] #store sessionid in session object
##                response['sid'] = sessionid

                if not self.req is None: #check if this is web request.                                        
                    self.req.session.set_timeout(onlot.TIMEOUT) # set session                    
                    self.req.session.save() # Save session. This is very important for persistence.                               
            elif result == 2: #Incorrect password or userid
                #don't set any session here
                response[responseCode] = 2;
            elif result == 3: #account is not validated yet
                #again don't set any session here
                ""
            elif result == 4: #user is logged in at another terminal
                response[responseCode] = 4;
            elif result == 5: #Only Retailer can create a cardid
                response[responseCode] = 5;
                ""
                
        my.destroy(rs)
        return json.dumps([response]) #o/p to the client browser
示例#2
0
    def logout(self, sid):
        responseCode = 'responseCode'
        response = {responseCode: onlot.SUCCESS} #reponsecode for success

        #if this is web request
        rs = my.proc("proc_ssl_retailerlogout('%s');" % (sid,))
        if rs.recordcount > 0:
           result = rs.Fields['result']
           #SUCESS in client and server script is "result - 1" from database
           response[responseCode] = result

           if not self.req is None:
               self.req.session.invalidate() #clear session details from apache web server and mod_python

        my.destroy(rs)
        return json.dumps( [response] ) #o/p to clietn browser