module Cally::Methods

Public Instance Methods

admin_or_same_user?() click to toggle source
# File lib/cally/methods.rb, line 31
def admin_or_same_user?
  # checks if the user loggedin is the same user requesting the action
  # or the user is administrator
  if logged_in? && (current_user == @user || current_user.admin)
    return true
  else
    flash[:error] = 'You can only perform this action as your own or an admin account.'
    if logged_in?
      redirect_to cally.user_path(current_user)
    else
      redirect_to cally.login_path
    end
  end
end
logged_in_as_admin?() click to toggle source
# File lib/cally/methods.rb, line 16
def logged_in_as_admin?
  # checks if the loggedin user has administrator rights
  if logged_in? && current_user.admin
    return true
  else
    flash[:error] = 'You need to be admin for this action.'
    if logged_in?
      redirect_to cally.user_path(current_user)
    else
      redirect_to cally.login_path
    end
    return false
  end
end
same_user?() click to toggle source
# File lib/cally/methods.rb, line 5
def same_user?
  # checks if the loggedin user is the same as the user requesting this action
  if logged_in? && current_user == @user
    return true
  else
    flash[:error] = 'You can only view your own profile.'
    redirect_to cally.login_path
    return false
  end
end
set_mailgun_prefix() click to toggle source
# File lib/cally/methods.rb, line 54
def set_mailgun_prefix
  @mailgun_prefix = ENV['MAILGUN_PREFIX'] || 'cally/'
end
test_env?() click to toggle source
# File lib/cally/methods.rb, line 46
def test_env?
  if Rails.env.development? || Rails.env.production?
    return false
  else
    return true
  end
end