From 38c309c216e9e77ba16bb6f57f1125148e87b5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 6 Sep 2019 18:50:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/user/usersInfo/InfosTopics.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/user/usersInfo/InfosTopics.js b/public/react/src/modules/user/usersInfo/InfosTopics.js index 2cffce0ec..d90feed0f 100644 --- a/public/react/src/modules/user/usersInfo/InfosTopics.js +++ b/public/react/src/modules/user/usersInfo/InfosTopics.js @@ -74,7 +74,7 @@ class InfosTopics extends Component{ isSpin:true }) let types=this.props.match.params.topicstype; - let user_id=undefined; + let user_id=""; if(types==="publicly"){ user_id=this.props.current_user&&this.props.current_user.login; @@ -83,7 +83,7 @@ class InfosTopics extends Component{ } if(user_id!=undefined){ - + console.log(user_id) let {per_page}=this.state; let url=`/users/${user_id}/question_banks.json`; From 1d86e0f641bfb9fa4d6fe1a212caedae6fe05ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 6 Sep 2019 19:01:26 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 20 ++++++------ .../src/modules/user/usersInfo/InfosTopics.js | 32 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 939d2cdaa..2fbee86da 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -21,16 +21,16 @@ let hashTimeout // TODO 开发期多个身份切换 let debugType ="" -if (isDev) { - const _search = window.location.search; - let parsed = {}; - if (_search) { - parsed = queryString.parse(_search); - } - debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : - window.location.search.indexOf('debug=s') != -1 ? 'student' : - window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' -} +// if (isDev) { +// const _search = window.location.search; +// let parsed = {}; +// if (_search) { +// parsed = queryString.parse(_search); +// } +// debugType = window.location.search.indexOf('debug=t') != -1 ? 'teacher' : +// window.location.search.indexOf('debug=s') != -1 ? 'student' : +// window.location.search.indexOf('debug=a') != -1 ? 'admin' : parsed.debug || 'admin' +// } window._debugType = debugType; export function initAxiosInterceptors(props) { diff --git a/public/react/src/modules/user/usersInfo/InfosTopics.js b/public/react/src/modules/user/usersInfo/InfosTopics.js index d90feed0f..edd7e554a 100644 --- a/public/react/src/modules/user/usersInfo/InfosTopics.js +++ b/public/react/src/modules/user/usersInfo/InfosTopics.js @@ -70,20 +70,22 @@ class InfosTopics extends Component{ // }else{ // // } - this.setState({ - isSpin:true - }) - let types=this.props.match.params.topicstype; - let user_id=""; + this.setState({ + isSpin:true + }) + let types=this.props.match.params.topicstype; + let user_id=""; + + if(types==="publicly"){ + user_id=this.props.current_user&&this.props.current_user.login; + }else{ + user_id=this.props.match.params&&this.props.match.params.username; + } - if(types==="publicly"){ - user_id=this.props.current_user&&this.props.current_user.login; - }else{ - user_id=this.props.match.params&&this.props.match.params.username; - } - if(user_id!=undefined){ - console.log(user_id) + if(user_id===undefined){ + user_id=this.props.match.params&&this.props.match.params.username; + } let {per_page}=this.state; let url=`/users/${user_id}/question_banks.json`; @@ -107,11 +109,7 @@ class InfosTopics extends Component{ isSpin:false }) }); - }else{ - this.setState({ - isSpin:false - }) - } + } searchCategory=(type)=>{ From 8d7af860c40d04ba30cc4f1f2034a185d83867f4 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 6 Sep 2019 19:08:56 +0800 Subject: [PATCH 3/3] tiaoz --- app/controllers/application_controller.rb | 2 +- app/controllers/users/question_banks_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 86d6312ab..a15e2b5ab 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base # 题库的访问权限 def bank_visit_auth - tip_exception("未通过职业认证") if current_user.is_teacher? && !current_user.certification_teacher? && !current_user.admin? && @bank.user_id != current_user.id && @bank.is_public + tip_exception(-2,"未通过职业认证") if current_user.is_teacher? && !current_user.certification_teacher? && !current_user.admin? && @bank.user_id != current_user.id && @bank.is_public tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? || (current_user.certification_teacher? && @bank.is_public) end diff --git a/app/controllers/users/question_banks_controller.rb b/app/controllers/users/question_banks_controller.rb index d6a2fcc88..76523eca4 100644 --- a/app/controllers/users/question_banks_controller.rb +++ b/app/controllers/users/question_banks_controller.rb @@ -65,7 +65,7 @@ class Users::QuestionBanksController < Users::BaseController def check_user_permission! if params[:type] == 'publicly' - render_error("未通过职业认证") unless User.current.admin? || User.current.certification_teacher? + normal_status(-2,"未通过职业认证") unless User.current.admin? || User.current.certification_teacher? else render_forbidden unless User.current.admin? || User.current.is_teacher? end