diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2016-08-11 23:01:34 +0300 |
---|---|---|
committer | Benjamin Neff <benjamin@coding4coffee.ch> | 2016-08-13 02:47:27 +0300 |
commit | 66b7b7e27a6c7e00c3de536fa9f3a113910b6baf (patch) | |
tree | 6a10b3f9de8b0a995a444b4f977a0dd6dd8310b1 /app/controllers | |
parent | 6cf1cd5d7657e58eb93e18df8576978f403ae8a2 (diff) |
Cleanup legacy invitations from code
Fixes #5116
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/invitations_controller.rb | 41 | ||||
-rw-r--r-- | app/controllers/registrations_controller.rb | 6 |
2 files changed, 7 insertions, 40 deletions
diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 6acf3602d..ebfff4a7c 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -4,7 +4,7 @@ class InvitationsController < ApplicationController - before_action :authenticate_user!, :only => [:new, :create] + before_action :authenticate_user! def new @invite_code = current_user.invitation_code @@ -19,36 +19,6 @@ class InvitationsController < ApplicationController end end - # this is for legacy invites. We try to look the person who sent them the - # invite, and use their new invite code - # owe will be removing this eventually - # @depreciated - def edit - user = User.find_by_invitation_token(params[:invitation_token]) - invitation_code = user.ugly_accept_invitation_code - redirect_to invite_code_path(invitation_code) - end - - def email - @invitation_code = - if params[:invitation_token] - # this is for legacy invites. - user = User.find_by_invitation_token(params[:invitation_token]) - - user.ugly_accept_invitation_code if user - else - params[:invitation_code] - end - @inviter = user || InvitationCode.where(id: params[:invitation_code]).first.try(:user) - if @invitation_code.present? - render 'notifier/invite', :layout => false - else - flash[:error] = t('invitations.check_token.not_found') - - redirect_to root_url - end - end - def create emails = inviter_params[:emails].split(',').map(&:strip).uniq @@ -78,15 +48,8 @@ class InvitationsController < ApplicationController redirect_to :back end - def check_if_invites_open - unless AppConfig.settings.invitations.open? - flash[:error] = I18n.t 'invitations.create.no_more' - - redirect_to :back - end - end - private + def valid_email?(email) User.email_regexp.match(email).present? end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 8b816e390..5614fc112 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -56,6 +56,10 @@ class RegistrationsController < Devise::RegistrationsController helper_method :invite def user_params - params.require(:user).permit(:username, :email, :getting_started, :password, :password_confirmation, :language, :disable_mail, :invitation_service, :invitation_identifier, :show_community_spotlight_in_stream, :auto_follow_back, :auto_follow_back_aspect_id, :remember_me, :captcha, :captcha_key) + params.require(:user).permit( + :username, :email, :getting_started, :password, :password_confirmation, :language, :disable_mail, + :show_community_spotlight_in_stream, :auto_follow_back, :auto_follow_back_aspect_id, + :remember_me, :captcha, :captcha_key + ) end end |