def validate(self):
super(LoginForm, self).validate()
try:
response = AuthClient(username=self.username.data,
password=self.password.data).token.new('xivo_admin', expiration=60*60*12)
except HTTPError as e:
if unauthorized(e):
self.username.errors.append(USERNAME_PASSWORD_ERROR)
self.password.errors.append(USERNAME_PASSWORD_ERROR)
return False
raise ValidationError(l_('Error with Wazo authentication server: %(error)s', error=e.message))
except requests.ConnectionError:
raise ValidationError(l_('Wazo authentication server connection error'))
self.user = UserUI(response['token'], response['auth_id'])
return True
评论列表
文章目录