예제 #1
0
    def setUp(self):
        self.clear_user_data()

        self.target = "http://localhost:2368"
        self.execute("target-set", self.target)

        self.username = "******" % randint(1, 1000000)
        self.password = "******"
        self.user = User.create(email=self.username, password=self.password)
        expect(self.user).not_to_be_null()

        self.execute("login", self.username, password=self.password)
예제 #2
0
    def get(self):
        email = self.request.headers.get("Email", None)
        password = self.request.headers.get("Password", None)

        if not email or not password:
            self.set_status(400)
            self.finish()
            return

        user = User.create(email, password)

        if user is None:
            self.set_status(409)
            self.write("User already registered.")
            self.finish()
            return

        exists, user = User.authenticate(email, password)

        self.set_status(200)
        self.write("OK")
        self.set_header("Token", user.token)
        self.set_header("Token-Expiration", user.token_expiration.isoformat())
        self.finish()
예제 #3
0
    def get(self):
        email = self.request.headers.get("Email", None)
        password = self.request.headers.get("Password", None)

        if not email or not password:
            self.set_status(400)
            self.finish()
            return

        user = User.create(email, password)

        if user is None:
            self.set_status(409)
            self.write("User already registered.")
            self.finish()
            return

        exists, user = User.authenticate(email, password)

        self.set_status(200)
        self.write("OK")
        self.set_header("Token", user.token)
        self.set_header("Token-Expiration", user.token_expiration.isoformat())
        self.finish()
예제 #4
0
 def test_cant_create_user_with_same_email_twice(self):
     user = UserFactory.create()
     user = User.create(email=user.email, password="******")
     expect(user).to_be_null()
예제 #5
0
 def test_cant_create_user_with_same_email_twice(self):
     user = UserFactory.create()
     user = User.create(email=user.email, password="******")
     expect(user).to_be_null()