Пример #1
0
 def test_password(self):
     passwd = 'test_password'
     ucontr = UserController()
     user = ucontr.create(login=passwd, password=passwd)
     self.assertNotEquals(passwd, user.password)
     self.assertTrue(ucontr.check_password(user, passwd))
     self.assertFalse(ucontr.check_password(user, passwd * 2))
     passwd *= 2
     ucontr.update({'id': user.id}, {'password': passwd})
     user = ucontr.get(id=user.id)
     self.assertNotEquals(passwd, user.password)
     self.assertTrue(ucontr.check_password(user, passwd))
     self.assertFalse(ucontr.check_password(user, passwd * 2))
Пример #2
0
 def wrapper(*args, **kwargs):
     if request.authorization:
         ucontr = UserController()
         try:
             user = ucontr.get(nickname=request.authorization.username)
         except NotFound:
             raise Forbidden("Couldn't authenticate your user")
         if not ucontr.check_password(user, request.authorization.password):
             raise Forbidden("Couldn't authenticate your user")
         if not user.is_active:
             raise Forbidden("User is desactivated")
         login_user_bundle(user)
     if current_user.is_authenticated:
         return func(*args, **kwargs)
     raise Unauthorized()
Пример #3
0
 def wrapper(*args, **kwargs):
     if request.authorization:
         ucontr = UserController()
         try:
             user = ucontr.get(login=request.authorization.username)
         except NotFound:
             raise Forbidden("Couldn't authenticate your user")
         if not ucontr.check_password(user, request.authorization.password):
             raise Forbidden("Couldn't authenticate your user")
         if not user.is_active:
             raise Forbidden("User is desactivated")
         login_user_bundle(user)
     if current_user.is_authenticated:
         return func(*args, **kwargs)
     raise Unauthorized()
Пример #4
0
def auth_func(*args, **kw):
    if request.authorization:
        ucontr = UserController()
        try:
            user = ucontr.get(nickname=request.authorization.username)
        except NotFound:
            raise ProcessingException("Couldn't authenticate your user",
                                        code=401)
        if not ucontr.check_password(user, request.authorization.password):
            raise ProcessingException("Couldn't authenticate your user",
                                        code=401)
        if not user.is_active:
            raise ProcessingException("User is desactivated", code=401)
        login_user_bundle(user)
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not authenticated!', code=401)
Пример #5
0
def auth_func(*args, **kw):
    if request.authorization:
        ucontr = UserController()
        try:
            user = ucontr.get(nickname=request.authorization.username)
        except NotFound:
            raise ProcessingException("Couldn't authenticate your user",
                                      code=401)
        if not ucontr.check_password(user, request.authorization.password):
            raise ProcessingException("Couldn't authenticate your user",
                                      code=401)
        if not user.is_active:
            raise ProcessingException("User is deactivated", code=401)
        login_user_bundle(user)
    if not current_user.is_authenticated:
        raise ProcessingException(description='Not authenticated!', code=401)
Пример #6
0
 def validate(self):
     validated = super().validate()
     ucontr = UserController()
     try:
         user = ucontr.get(nickname=self.nickmane.data)
     except NotFound:
         self.nickmane.errors.append("Wrong nickname")
         validated = False
     else:
         if not user.is_active:
             self.nickmane.errors.append("Account not active")
             validated = False
         if not ucontr.check_password(user, self.password.data):
             self.password.errors.append("Wrong password")
             validated = False
         self.user = user
     return validated
Пример #7
0
 def validate(self):
     validated = super().validate()
     ucontr = UserController()
     try:
         user = ucontr.get(login=self.login.data)
     except NotFound:
         self.login.errors.append('Wrong login')
         validated = False
     else:
         if not user.is_active:
             self.login.errors.append('User is desactivated')
             validated = False
         if not ucontr.check_password(user, self.password.data):
             self.password.errors.append('Wrong password')
             validated = False
         self.user = user
     return validated
Пример #8
0
 def validate(self):
     validated = super().validate()
     ucontr = UserController()
     try:
         user = ucontr.get(login=self.login.data)
     except NotFound:
         self.login.errors.append('Wrong login')
         validated = False
     else:
         if not user.is_active:
             self.login.errors.append('User is desactivated')
             validated = False
         if not ucontr.check_password(user, self.password.data):
             self.password.errors.append('Wrong password')
             validated = False
         self.user = user
     return validated
Пример #9
0
Файл: forms.py Проект: JARR/JARR
 def validate(self):
     validated = super().validate()
     ucontr = UserController()
     try:
         user = ucontr.get(nickname=self.nickmane.data)
     except NotFound:
         self.nickmane.errors.append(
             'Wrong nickname')
         validated = False
     else:
         if not user.is_active:
             self.nickmane.errors.append('Account not active')
             validated = False
         if not ucontr.check_password(user, self.password.data):
             self.password.errors.append('Wrong password')
             validated = False
         self.user = user
     return validated
Пример #10
0
 def validate(self):
     validated = super().validate()
     ucontr = UserController()
     try:
         user = ucontr.get(**{'__or__':
                             {'email': self.email_or_nickmane.data,
                             'nickname': self.email_or_nickmane.data}})
     except NotFound:
         self.email_or_nickmane.errors.append(
             'Wrong email address or nickname')
         validated = False
     else:
         if not user.is_active:
             self.email_or_nickmane.errors.append('User is desactivated')
             validated = False
         if not ucontr.check_password(user, self.password.data):
             self.password.errors.append('Wrong password')
             validated = False
         self.user = user
     return validated
Пример #11
0
 def validate(self):
     validated = super().validate()
     ucontr = UserController()
     try:
         user = ucontr.get(
             **{
                 '__or__': {
                     'email': self.email_or_nickmane.data,
                     'nickname': self.email_or_nickmane.data
                 }
             })
     except NotFound:
         self.email_or_nickmane.errors.append(
             'Wrong email address or nickname')
         validated = False
     else:
         if not user.is_active:
             self.email_or_nickmane.errors.append('User is desactivated')
             validated = False
         if not ucontr.check_password(user, self.password.data):
             self.password.errors.append('Wrong password')
             validated = False
         self.user = user
     return validated