From 9fa9a22d541f18381bd3cea6d861fe10ef9d1cbe Mon Sep 17 00:00:00 2001 From: Andy Zhao Date: Mon, 9 Jul 2018 18:14:34 -0400 Subject: [PATCH] Add a comment for more public controllers (#553) --- app/controllers/notifications_controller.rb | 9 +++++---- app/controllers/omniauth_callbacks_controller.rb | 1 + app/controllers/registrations_controller.rb | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 1f356cb91..9b71d9de1 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,14 +1,15 @@ class NotificationsController < ApplicationController + # No authorization required for entirely public controller before_action :create_enricher def index if user_signed_in? @notifications_index = true @user = if params[:username] && current_user.is_admin? - User.find_by_username(params[:username]) - else - current_user - end + User.find_by_username(params[:username]) + else + current_user + end @activities = cached_activities @last_user_reaction = @user.reactions.pluck(:id).last @last_user_comment = @user.comments.pluck(:id).last diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 2e8d83349..4b995077d 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -1,4 +1,5 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController + # Don't need a policy for this since this is our sign up/in route include Devise::Controllers::Rememberable def self.provides_callback_for(provider) # raise env["omniauth.auth"].to_yaml diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 332d1b4e9..bf8b235bf 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -1,5 +1,7 @@ class RegistrationsController < Devise::RegistrationsController prepend_before_action :require_no_authentication, :only => [] + # No authorization required for public registration route + def new if user_signed_in? redirect_to "/dashboard?signed-in-already&t=#{Time.now.to_i}"