add notification settings, fix comment edit permissions

This commit is contained in:
jomo
2014-06-17 21:19:15 +02:00
parent 2564ea1aa6
commit 8a7d719920
9 changed files with 114 additions and 38 deletions

View File

@@ -4,7 +4,7 @@ class CommentsController < ApplicationController
def edit
@comment = Comment.find(params[:id])
if mod? || @comment.author.is?(current_user)
if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user)
else
flash[:alert] = "You are not allowed to edit this comment"
redirect_to @comment.blogpost
@@ -49,7 +49,7 @@ class CommentsController < ApplicationController
def destroy
@comment = Comment.find(params[:id])
if mod? || @comment.author.is?(current_user)
if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user)
if @comment.destroy
flash[:notice] = "Comment deleted!"
else

View File

@@ -204,6 +204,14 @@ class UsersController < ApplicationController
end
end
def edit_notifications
@user = User.find(params[:id])
unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin?
flash[:alert] = "You are not allowed to edit this user's notification settings!"
redirect_to @user
end
end
def edit_login
@user = User.find(params[:id])
unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin?
@@ -267,7 +275,7 @@ class UsersController < ApplicationController
end
def user_params(add = [])
a = [:ign, :email, :password, :password_confirmation] + add
a = [:ign, :email, :password, :password_confirmation, :mail_own_thread_reply, :mail_other_thread_reply, :mail_own_blogpost_comment, :mail_other_blogpost_comment, :mail_mention] + add
params.require(:user).permit(a)
end
end