def render_POST(self, request): if not self.post_method(): #log.debug("GET only method - dropping request") return utils.bad_request(request) try: data = json.load(request.content) return self._render(request, data) except: import traceback log.error("error: %s" % (traceback.format_exc(), )) return utils.bad_request(request)
def validate(self, request): '''Check a validation code and generates a user token to login with.''' code = request.args['c'][0] if not code or len(code) != utils.VALIDATION_CODE_LENGTH: return utils.bad_request(request) # lookup the verification code valdb = database.validations(self.broker.db) userid = valdb.get_userid(code) if userid: # damn unicode! userid = str(userid) # delete verification entry in validations table valdb.delete(code) # touch user so we get a first presence self.broker.usercache.touch_user(userid) # here is your token log.debug("generating token for %s" % (userid, )) str_token = token.user_token( userid, str(self.broker.config['server']['fingerprint'])) return {'auth': str_token, 'userid': userid} else: return utils.not_found(request)
def validate(self, request): '''Check a validation code and generates a user token to login with.''' code = request.args['c'][0] if not code or len(code) != utils.VALIDATION_CODE_LENGTH: return utils.bad_request(request) # lookup the verification code valdb = database.validations(self.broker.db) userid = valdb.get_userid(code) if userid: # damn unicode! userid = str(userid) # delete verification entry in validations table valdb.delete(code) # touch user so we get a first presence self.broker.usercache.touch_user(userid) # here is your token log.debug("generating token for %s" % (userid, )) str_token = token.user_token(userid, str(self.broker.config['server']['fingerprint'])) return {'auth': str_token, 'userid': userid } else: return utils.not_found(request)
def render_GET(self, request): if self.post_method(): #log.debug("POST only method - dropping request") return utils.bad_request(request) return self._render(request)
def render_GET(self, request): #log.debug("request from %s: %s" % (self.userid, request.args)) return utils.bad_request(request)