app/controllers/valid_emails_controller.rb
def update
    # only allow admins and moderators to whitelist emails
    redirect_to '/tasks' if current_user.role != 'admin' && current_user.role != 'moderator'

    @valid_email = ValidEmail.find(params[:id])
    if @valid_email.update(valid_email_params)
      redirect_to '/valid_emails'
    else
      render :new
    end
  end
# same protections as edit to have double protection
same protections as edit to have double protection
same protections as edit to have double protection
def update
    redirect_to '/tasks' if current_user.role != 'admin' && current_user.role != 'moderator'
    @valid_email = ValidEmail.find(params[:id])
    if @valid_email.update(valid_email_params)
      redirect_to '/valid_emails'
    else
      render :new
    end
  end
def update redirect_to '/tasks' if current_user . role != 'admin' && current_user . role != 'moderator' @valid_email = ValidEmail . find ( params [ :id ] ) if @valid_email . update ( valid_email_params ) redirect_to '/valid_emails' else render :new end end
same protections as edit to have double protection
same protections as edit to have double protection
# only allow admins and moderators to whitelist emails