From e48282e29bbb01ff119eb0dbf083024b782049d7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 11 Feb 2020 15:45:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/live_links_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/live_links_controller.rb b/app/controllers/live_links_controller.rb index f4b49d4aa..fe2de4afe 100644 --- a/app/controllers/live_links_controller.rb +++ b/app/controllers/live_links_controller.rb @@ -2,7 +2,8 @@ class LiveLinksController < ApplicationController before_action :require_login before_action :find_course, only: [:index, :create] before_action :user_course_identity, :teacher_allowed, only: [:create] - before_action :edit_auth, only: [:edit, :update, :destroy] + before_action :edit_auth, only: [:edit, :update] + before_action :delete_auth, only: [:destroy] def index lives = @course.live_links @@ -58,6 +59,10 @@ class LiveLinksController < ApplicationController end def edit_auth + tip_exception(403, "无权限操作") unless current_user.id == current_live.user_id || current_user.admin_or_business? + end + + def delete_auth tip_exception(403, "无权限操作") unless current_user.id == current_live.user_id || current_user.admin? end end \ No newline at end of file From c3c16bc0b4029c6ba87e5ae4bbb4332629c1073e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 11 Feb 2020 15:48:20 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/live_link.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/live_link.rb b/app/models/live_link.rb index 5dcfaf3d3..b1865071f 100644 --- a/app/models/live_link.rb +++ b/app/models/live_link.rb @@ -8,6 +8,6 @@ class LiveLink < ApplicationRecord validates :description, length: { maximum: 100, too_long: "不能超过100个字符" } def op_auth? - user == User.current || User.current.admin? + user == User.current || User.current.admin_or_business? end end From e13a86f299fd81c5b6cef5944728cadb3ad19f79 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 11 Feb 2020 15:50:04 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/live_link.rb | 4 ++++ app/views/live_links/index.json.jbuilder | 1 + 2 files changed, 5 insertions(+) diff --git a/app/models/live_link.rb b/app/models/live_link.rb index b1865071f..52c1e3657 100644 --- a/app/models/live_link.rb +++ b/app/models/live_link.rb @@ -10,4 +10,8 @@ class LiveLink < ApplicationRecord def op_auth? user == User.current || User.current.admin_or_business? end + + def delete_auth? + user == User.current || User.current.admin? + end end diff --git a/app/views/live_links/index.json.jbuilder b/app/views/live_links/index.json.jbuilder index e951f24bc..e497a068b 100644 --- a/app/views/live_links/index.json.jbuilder +++ b/app/views/live_links/index.json.jbuilder @@ -5,6 +5,7 @@ json.lives @lives do |live| json.author_login live.user.login json.author_img url_to_avatar(live.user) json.op_auth live.op_auth? + json.delete_auth live.delete_auth? json.created_at live.created_at.strftime('%Y-%m-%d') end json.my_live_id @my_live_id From f59a271c79d892122e13c0d54f4727f9ce883169 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Tue, 11 Feb 2020 15:55:54 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E7=9A=84=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/Video/LiveItem.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/public/react/src/modules/courses/Video/LiveItem.js b/public/react/src/modules/courses/Video/LiveItem.js index 095a8fc62..a2fff5b98 100644 --- a/public/react/src/modules/courses/Video/LiveItem.js +++ b/public/react/src/modules/courses/Video/LiveItem.js @@ -72,13 +72,18 @@ class LiveItem extends Component{
创建时间:{item.created_at}
- {
- item.op_auth ?
+
-