예제 #1
0
    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)
예제 #2
0
    def validate_user(self, tx_id, code):
        if not code or len(code) != utils.VALIDATION_CODE_LENGTH:
            return c2s.ValidationResponse.STATUS_FAILED, None

        # 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("[%s] generating token for %s" % (tx_id, userid))
            str_token = token.user_token(
                userid, str(self.config['server']['fingerprint']))
            return c2s.ValidationResponse.STATUS_SUCCESS, str_token

        else:
            return c2s.ValidationResponse.STATUS_FAILED, None
예제 #3
0
    def validate_user(self, tx_id, code):
        if not code or len(code) != utils.VALIDATION_CODE_LENGTH:
            return c2s.ValidationResponse.STATUS_FAILED, None

        # 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("[%s] generating token for %s" % (tx_id, userid))
            str_token = token.user_token(userid,
                str(self.config['server']['fingerprint']))
            return c2s.ValidationResponse.STATUS_SUCCESS, str_token

        else:
            return c2s.ValidationResponse.STATUS_FAILED, None
예제 #4
0
    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)