@POST('^/api/v1/login')
    def login(self, request):
        request.setHeader('content-type', "application/json")
        if request.getHost().host in self.failed_login_attempts and \
                        self.failed_login_attempts[request.getHost().host] >= 7:
            return json.dumps({"success": False, "reason": "too many attempts"})
        try:
            if request.args["username"][0] == self.username and request.args["password"][0] == self.password:
                self.authenticated_sessions.append(request.getSession())
                if request.getHost().host in self.failed_login_attempts:
                    del self.failed_login_attempts[request.getHost().host]
                return json.dumps({"success": True})
            else:
                raise Exception("Invalid credentials")
        except Exception:
            self._failed_login(request.getHost().host)
            return json.dumps({"success": False, "reason": "invalid username or password"})
dataset/ETHPy150Open OpenBazaar/OpenBazaar-Server/api/restapi.py/OpenBazaarAPI.login/original