Exemplo n.º 1
0
def login(request):
    json = simplejson.loads(request.raw_post_data)
    user = json['user']
    password = json['password']
    login_result = UsersModel.login(user, password)
    if login_result >= 1:
        json = { 'errCode' : 1, 'count' : login_result }
    else:
        json = { 'errCode' : login_result }
    return HttpResponse(simplejson.dumps(json), content_type="application/json")
Exemplo n.º 2
0
    def testUsersHaveSeparateCounts(self):
        UsersModel.add("user1", "password")
        UsersModel.add("user2", "password")

        UsersModel.login('user1', "password")
        UsersModel.login('user1', "password")
        UsersModel.login('user2', "password")

        self.assertEquals(3, UsersModel.objects.get(user="******").count)
        self.assertEquals(2, UsersModel.objects.get(user="******").count)
Exemplo n.º 3
0
 def testLoginExists(self):
     self.assertEquals(settings.STATUS_CODES['ERR_BAD_CREDENTIALS'], UsersModel.login('baduser', 'password'));
Exemplo n.º 4
0
 def testLoginIncrementsCount(self):
     UsersModel.add("user1", "password")
     UsersModel.login('user1', "password")
     self.assertEquals(2, UsersModel.objects.get(user="******").count)