MOD:
Showing
2 changed files
with
38 additions
and
38 deletions
| ... | @@ -28,35 +28,35 @@ client_id_base64 = base64.b64encode('{0}:{1}'.format( | ... | @@ -28,35 +28,35 @@ client_id_base64 = base64.b64encode('{0}:{1}'.format( |
| 28 | conf.IWA_CLIENT_ID, conf.IWA_CLIENT_SECRET).encode('utf-8')).decode('utf-8') | 28 | conf.IWA_CLIENT_ID, conf.IWA_CLIENT_SECRET).encode('utf-8')).decode('utf-8') |
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | class LoginView(ObtainJSONWebToken, GenericView): | 31 | # class LoginView(ObtainJSONWebToken, GenericView): |
| 32 | 32 | ||
| 33 | def post(self, request, *args, **kwargs): | 33 | # def post(self, request, *args, **kwargs): |
| 34 | # 登录次数限制 | 34 | # # 登录次数限制 |
| 35 | remote_ip = request.META.get('HTTP_X_REAL_IP', '') | 35 | # remote_ip = request.META.get('HTTP_X_REAL_IP', '') |
| 36 | user_name = request.data.get('username', '') | 36 | # user_name = request.data.get('username', '') |
| 37 | times = rh.get_login_times(remote_ip) | 37 | # times = rh.get_login_times(remote_ip) |
| 38 | if isinstance(times, str) and int(times) >= LOGIN_TIMES_LIMIT: | 38 | # if isinstance(times, str) and int(times) >= LOGIN_TIMES_LIMIT: |
| 39 | raise self.invalid_params(msg="重试次数限制") | 39 | # raise self.invalid_params(msg="重试次数限制") |
| 40 | 40 | ||
| 41 | res = super(LoginView, self).post(request, *args, **kwargs) | 41 | # res = super(LoginView, self).post(request, *args, **kwargs) |
| 42 | self.running_log.info('[users.login] username: {0}'.format(user_name)) | 42 | # self.running_log.info('[users.login] username: {0}'.format(user_name)) |
| 43 | 43 | ||
| 44 | if res.status_code == status.HTTP_400_BAD_REQUEST: | 44 | # if res.status_code == status.HTTP_400_BAD_REQUEST: |
| 45 | rh.set_login_times(remote_ip, LOGIN_TIMES_LIMIT_EXPIRES) | 45 | # rh.set_login_times(remote_ip, LOGIN_TIMES_LIMIT_EXPIRES) |
| 46 | raise self.invalid_params(msg="用户名或密码错误") | 46 | # raise self.invalid_params(msg="用户名或密码错误") |
| 47 | serializer = self.get_serializer(data=request.data) | 47 | # serializer = self.get_serializer(data=request.data) |
| 48 | serializer.is_valid() | 48 | # serializer.is_valid() |
| 49 | user = serializer.object.get('user') | 49 | # user = serializer.object.get('user') |
| 50 | user_role = UserRole.objects.filter(auth_user_id=user.id).first() | 50 | # user_role = UserRole.objects.filter(auth_user_id=user.id).first() |
| 51 | data = { | 51 | # data = { |
| 52 | 'user_id': user.id, | 52 | # 'user_id': user.id, |
| 53 | 'user_name': user.username, | 53 | # 'user_name': user.username, |
| 54 | 'token': res.data.get('token'), | 54 | # 'token': res.data.get('token'), |
| 55 | 'role': user_role.role if user_role else -1 | 55 | # 'role': user_role.role if user_role else -1 |
| 56 | } | 56 | # } |
| 57 | rh.set_token(res.data.get('token')[-10:], user.username) | 57 | # rh.set_token(res.data.get('token')[-10:], user.username) |
| 58 | rh.set_token(res.data.get('token')[-11:], user_role.role if user_role else -1) | 58 | # rh.set_token(res.data.get('token')[-11:], user_role.role if user_role else -1) |
| 59 | return response.ok(data=data) | 59 | # return response.ok(data=data) |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | class IWALoginView(IWABaseView, GenericView): | 62 | class IWALoginView(IWABaseView, GenericView): | ... | ... |
| ... | @@ -1070,7 +1070,7 @@ class DocView(DocGenericView, DocHandler): | ... | @@ -1070,7 +1070,7 @@ class DocView(DocGenericView, DocHandler): |
| 1070 | token = request.META.get("HTTP_AUTHORIZATION") | 1070 | token = request.META.get("HTTP_AUTHORIZATION") |
| 1071 | user_role = rh.get_token(token[-11:]) | 1071 | user_role = rh.get_token(token[-11:]) |
| 1072 | self.running_log.info('[api doc] [user_role={0} business_type={1}] '.format(user_role, business_type)) | 1072 | self.running_log.info('[api doc] [user_role={0} business_type={1}] '.format(user_role, business_type)) |
| 1073 | if user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): | 1073 | if user_role or user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): |
| 1074 | pagination = {'current': page, 'total': 0, 'page_size': page_size} | 1074 | pagination = {'current': page, 'total': 0, 'page_size': page_size} |
| 1075 | res = { | 1075 | res = { |
| 1076 | 'pagination': pagination, | 1076 | 'pagination': pagination, |
| ... | @@ -1247,8 +1247,8 @@ class CompareResultView(GenericView): | ... | @@ -1247,8 +1247,8 @@ class CompareResultView(GenericView): |
| 1247 | # 角色权限不符,返回异常 | 1247 | # 角色权限不符,返回异常 |
| 1248 | token = request.META.get("HTTP_AUTHORIZATION") | 1248 | token = request.META.get("HTTP_AUTHORIZATION") |
| 1249 | user_role = rh.get_token(token[-11:]) | 1249 | user_role = rh.get_token(token[-11:]) |
| 1250 | self.running_log.info('[api doc] [user_role={0}] '.format(user_role)) | 1250 | self.running_log.info('[CompareResultView] [user_role={0}] '.format(user_role)) |
| 1251 | if user_role == '-1' or (user_role == '1' and entity == 'HIL') or (user_role == '2' and entity == 'AFC'): | 1251 | if user_role or user_role == '-1' or (user_role == '1' and entity == 'HIL') or (user_role == '2' and entity == 'AFC'): |
| 1252 | raise NoPermissionException('no permission') | 1252 | raise NoPermissionException('no permission') |
| 1253 | 1253 | ||
| 1254 | if is_auto == 1: | 1254 | if is_auto == 1: |
| ... | @@ -1644,8 +1644,8 @@ class AutoSettlementView(GenericView): | ... | @@ -1644,8 +1644,8 @@ class AutoSettlementView(GenericView): |
| 1644 | # 角色权限不符,返回空列表 | 1644 | # 角色权限不符,返回空列表 |
| 1645 | token = request.META.get("HTTP_AUTHORIZATION") | 1645 | token = request.META.get("HTTP_AUTHORIZATION") |
| 1646 | user_role = rh.get_token(token[-11:]) | 1646 | user_role = rh.get_token(token[-11:]) |
| 1647 | self.running_log.info('[api doc] [user_role={0}] '.format(user_role)) | 1647 | self.running_log.info('[AutoSettlementView] [user_role={0}] '.format(user_role)) |
| 1648 | if user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): | 1648 | if user_role or user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): |
| 1649 | pagination = {'current': page, 'total': 0, 'page_size': page_size} | 1649 | pagination = {'current': page, 'total': 0, 'page_size': page_size} |
| 1650 | res = { | 1650 | res = { |
| 1651 | 'pagination': pagination, | 1651 | 'pagination': pagination, |
| ... | @@ -1740,8 +1740,8 @@ class AutoSettlementExcelView(GenericView): | ... | @@ -1740,8 +1740,8 @@ class AutoSettlementExcelView(GenericView): |
| 1740 | # 角色权限不符,返回异常 | 1740 | # 角色权限不符,返回异常 |
| 1741 | token = request.META.get("HTTP_AUTHORIZATION") | 1741 | token = request.META.get("HTTP_AUTHORIZATION") |
| 1742 | user_role = rh.get_token(token[-11:]) | 1742 | user_role = rh.get_token(token[-11:]) |
| 1743 | self.running_log.info('[api doc] [user_role={0}] '.format(user_role)) | 1743 | self.running_log.info('[AutoSettlementExcelView] [user_role={0}] '.format(user_role)) |
| 1744 | if user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): | 1744 | if user_role or user_role == '-1' or (user_role == '1' and business_type == 'HIL') or (user_role == '2' and business_type == 'AFC'): |
| 1745 | raise NoPermissionException('no permission') | 1745 | raise NoPermissionException('no permission') |
| 1746 | 1746 | ||
| 1747 | if isinstance(auto_result, int): | 1747 | if isinstance(auto_result, int): |
| ... | @@ -1906,7 +1906,7 @@ class InvoiceExcelView(GenericView): | ... | @@ -1906,7 +1906,7 @@ class InvoiceExcelView(GenericView): |
| 1906 | token = request.META.get("HTTP_AUTHORIZATION") | 1906 | token = request.META.get("HTTP_AUTHORIZATION") |
| 1907 | user_role = rh.get_token(token[-11:]) | 1907 | user_role = rh.get_token(token[-11:]) |
| 1908 | self.running_log.info('[InvoiceExcelView] [user_role={0}] '.format(user_role)) | 1908 | self.running_log.info('[InvoiceExcelView] [user_role={0}] '.format(user_role)) |
| 1909 | if user_role == '-1' or (user_role == '1' and application_entity == 'HIL') or (user_role == '2' and application_entity == 'AFC'): | 1909 | if user_role or user_role == '-1' or (user_role == '1' and application_entity == 'HIL') or (user_role == '2' and application_entity == 'AFC'): |
| 1910 | raise NoPermissionException('no permission') | 1910 | raise NoPermissionException('no permission') |
| 1911 | 1911 | ||
| 1912 | url = 'http://127.0.0.1:8088/napi/invoice/downloadExcelOri' | 1912 | url = 'http://127.0.0.1:8088/napi/invoice/downloadExcelOri' |
| ... | @@ -1950,7 +1950,7 @@ class InvoiceQueryInfoView(GenericView): | ... | @@ -1950,7 +1950,7 @@ class InvoiceQueryInfoView(GenericView): |
| 1950 | token = request.META.get("HTTP_AUTHORIZATION") | 1950 | token = request.META.get("HTTP_AUTHORIZATION") |
| 1951 | user_role = rh.get_token(token[-11:]) | 1951 | user_role = rh.get_token(token[-11:]) |
| 1952 | self.running_log.info('[InvoiceQueryInfoView] [user_role={0}] '.format(user_role)) | 1952 | self.running_log.info('[InvoiceQueryInfoView] [user_role={0}] '.format(user_role)) |
| 1953 | if user_role == '-1' or (user_role == '1' and application_entity == 'HIL') or (user_role == '2' and application_entity == 'AFC'): | 1953 | if user_role or user_role == '-1' or (user_role == '1' and application_entity == 'HIL') or (user_role == '2' and application_entity == 'AFC'): |
| 1954 | raise NoPermissionException('no permission') | 1954 | raise NoPermissionException('no permission') |
| 1955 | 1955 | ||
| 1956 | url = 'http://127.0.0.1:8088/napi/invoice/queryInfoOri' | 1956 | url = 'http://127.0.0.1:8088/napi/invoice/queryInfoOri' | ... | ... |
-
Please register or sign in to post a comment