forked from External/greenlight
GRN2-196: Fixed issues that scrutinizer is complaining about (#765)
* Refactored code to improve scrutinizer score * Bug fixes
This commit is contained in:
@ -43,4 +43,33 @@ module Registrar
|
||||
{ present: false, verified: false }
|
||||
end
|
||||
end
|
||||
|
||||
# Checks if the user passes the requirements to be invited
|
||||
def passes_invite_reqs
|
||||
# check if user needs to be invited and IS invited
|
||||
invitation = check_user_invited(@user.email, session[:invite_token], @user_domain)
|
||||
|
||||
@user.email_verified = true if invitation[:verified]
|
||||
|
||||
invitation[:present]
|
||||
end
|
||||
|
||||
# Add validation errors to model if they exist
|
||||
def valid_user_or_captcha
|
||||
valid_user = @user.valid?
|
||||
valid_captcha = Rails.configuration.recaptcha_enabled ? verify_recaptcha(model: @user) : true
|
||||
|
||||
logger.error("Support: #{@user.email} creation failed: User params are not valid.") unless valid_user
|
||||
|
||||
valid_user && valid_captcha
|
||||
end
|
||||
|
||||
# Checks if the user trying to sign in with twitter account
|
||||
def check_if_twitter_account(log_out = false)
|
||||
unless params[:old_twitter_user_id].nil? && session[:old_twitter_user_id].nil?
|
||||
logout if log_out
|
||||
flash.now[:alert] = I18n.t("registration.deprecated.new_signin")
|
||||
session[:old_twitter_user_id] = params[:old_twitter_user_id] unless params[:old_twitter_user_id].nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user