MOD:为了测试先恢复本地登录
Showing
2 changed files
with
30 additions
and
30 deletions
| ... | @@ -3,7 +3,7 @@ from . import views | ... | @@ -3,7 +3,7 @@ from . import views |
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | urlpatterns = [ | 5 | urlpatterns = [ |
| 6 | # path(r'login/', views.LoginView.as_view()), | 6 | path(r'login/', views.LoginView.as_view()), |
| 7 | path(r'iwalogin/', views.IWALoginView.as_view()), | 7 | path(r'iwalogin/', views.IWALoginView.as_view()), |
| 8 | path(r'iwaurl/', views.IWAUrlView.as_view()), | 8 | path(r'iwaurl/', views.IWAUrlView.as_view()), |
| 9 | path(r'adminlogin/', views.AdminLoginView.as_view()), | 9 | path(r'adminlogin/', views.AdminLoginView.as_view()), | ... | ... |
| ... | @@ -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): | ... | ... |
-
Please register or sign in to post a comment