Exemplo n.º 1
0
    def test_getuser(self):
        gideon = users.create("gideon", "secret", "*****@*****.**")

        g2 = users.getuser("gideon")
        self.assertEquals(gideon.username, g2.username)
        self.assertEquals(gideon.hashpass, g2.hashpass)
        self.assertEquals(gideon.email, g2.email)

        self.assertRaises(users.NoSuchUser, users.getuser, "rynge")
Exemplo n.º 2
0
    def test_passwd(self):
        gideon = users.create("gideon", "secret", "*****@*****.**")
        self.assertTrue(gideon.password_matches("secret")) # original passwd

        users.passwd("gideon", "newsecret")
        self.assertTrue(gideon.password_matches("newsecret")) # new passwd

        gideon2 = users.getuser("gideon")
        self.assertTrue(gideon2.password_matches("newsecret")) # new passwd
Exemplo n.º 3
0
def authenticate(username, password):
    "Check username/password"
    try:
        user = users.getuser(username)
        if not user.password_matches(password):
            return False

        # This makes the user object available to the entire app
        g.user = user

        return True
    except users.NoSuchUser:
        return False
Exemplo n.º 4
0
def authenticate(username, password):
    "Check username/password"
    try:
        user = users.getuser(username)
        if not user.password_matches(password):
            return False

        # This makes the user object available to the entire app
        g.user = user

        return True
    except users.NoSuchUser:
        return False