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))
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()
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()
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)
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)
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
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
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
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
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
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