Ejemplo n.º 1
0
    def test_get(self):
        # Create the usernames key so we can do autocomplete
        r_client.zadd('qiita-usernames', **{u: 0 for u in User.iter()})
        response = self.get(self.base_url % 't')
        self.assertEqual(response.code, 200)
        self.assertEqual(
            loads(response.body),
            {'results': [{
                "id": "*****@*****.**",
                "text": "*****@*****.**"
            }]})

        response = self.get(self.base_url % 'admi')
        self.assertEqual(response.code, 200)
        self.assertEqual(
            loads(response.body),
            {'results': [{
                "id": "*****@*****.**",
                "text": "*****@*****.**"
            }]})

        response = self.get(self.base_url % 'tesq')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body), {'results': []})

        r_client.delete('qiita-usernames')
Ejemplo n.º 2
0
 def get(self, code):
     email = self.get_argument("email").strip().lower()
     if User.verify_code(email, code, "create"):
         msg = "Successfully verified user! You are now free to log in."
         color = "black"
         r_client.zadd('qiita-usernames', email, 0)
     else:
         msg = "Code not valid!"
         color = "red"
     self.render("user_verified.html", msg=msg, color=color,
                 email=self.get_argument("email").strip())
Ejemplo n.º 3
0
 def get(self, code):
     email = self.get_argument("email").strip().lower()
     if User.verify_code(email, code, "create"):
         msg = "Successfully verified user! You are now free to log in."
         color = "black"
         r_client.zadd('qiita-usernames', email, 0)
     else:
         msg = "Code not valid!"
         color = "red"
     self.render("user_verified.html",
                 msg=msg,
                 color=color,
                 email=self.get_argument("email").strip())
Ejemplo n.º 4
0
    def test_get(self):
        # Create the usernames key so we can do autocomplete
        r_client.zadd('qiita-usernames', **{u: 0 for u in User.iter()})
        response = self.get(self.base_url % 't')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': [{"id": "*****@*****.**",
                                       "text": "*****@*****.**"}]})

        response = self.get(self.base_url % 'admi')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': [{"id": "*****@*****.**",
                                       "text": "*****@*****.**"}]})

        response = self.get(self.base_url % 'tesq')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': []})

        r_client.delete('qiita-usernames')
Ejemplo n.º 5
0
    def get(self, code):
        email = self.get_argument("email").strip().lower()

        code_is_valid = False
        msg = "This code is not valid."

        # an exception is raised if the 'code type' is not available, otherwise
        # the method determines the validity of the code
        try:
            code_is_valid = User.verify_code(email, code, "create")
        except QiitaDBError:
            msg = "This user has already created an account."

        if code_is_valid:
            msg = "Successfully verified user. You are now free to log in."
            color = "black"
            r_client.zadd('qiita-usernames', email, 0)
        else:
            color = "red"

        self.render("user_verified.html", msg=msg, color=color,
                    email=self.get_argument("email").strip())
Ejemplo n.º 6
0
    def get(self, code):
        email = self.get_argument("email").strip().lower()

        code_is_valid = False
        msg = "This code is not valid."

        # an exception is raised if the 'code type' is not available, otherwise
        # the method determines the validity of the code
        try:
            code_is_valid = User.verify_code(email, code, "create")
        except QiitaDBError:
            msg = "This user has already created an account."

        if code_is_valid:
            msg = "Successfully verified user. You are now free to log in."
            color = "black"
            r_client.zadd('qiita-usernames', email, 0)
        else:
            color = "red"

        self.render("user_verified.html",
                    msg=msg,
                    color=color,
                    email=self.get_argument("email").strip())