Module: SessionsHelper

Includes:
Gitlab::Utils::StrongMemoize
Included in:
ApplicationController, Gitlab::BaseDoorkeeperController
Defined in:
app/helpers/sessions_helper.rb

Instance Method Summary collapse

Instance Method Details

#obfuscated_email(email) ⇒ Object



10
11
12
13
# File 'app/helpers/sessions_helper.rb', line 10

def obfuscated_email(email)
  # Moved to Gitlab::Utils::Email in 15.9
  Gitlab::Utils::Email.obfuscated_email(email)
end

#remember_me_enabled?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/helpers/sessions_helper.rb', line 15

def remember_me_enabled?
  Gitlab::CurrentSettings.remember_me_enabled?
end

#unconfirmed_email?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/helpers/sessions_helper.rb', line 6

def unconfirmed_email?
  flash[:alert] == t(:unconfirmed, scope: [:devise, :failure])
end

#unconfirmed_verification_email?(user) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'app/helpers/sessions_helper.rb', line 19

def unconfirmed_verification_email?(user)
  token_valid_from = ::Users::EmailVerification::ValidateTokenService::TOKEN_VALID_FOR_MINUTES.minutes.ago
  user.email_reset_offered_at.nil? && user.pending_reconfirmation? && user.confirmation_sent_at >= token_valid_from
end

#verification_data(user) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/sessions_helper.rb', line 28

def verification_data(user)
  {
    username: user.username,
    obfuscated_email: obfuscated_email(verification_email(user)),
    verify_path: session_path(:user),
    resend_path: users_resend_verification_code_path,
    offer_email_reset: user.email_reset_offered_at.nil?.to_s,
    update_email_path: users_update_email_path
  }
end

#verification_email(user) ⇒ Object



24
25
26
# File 'app/helpers/sessions_helper.rb', line 24

def verification_email(user)
  unconfirmed_verification_email?(user) ? user.unconfirmed_email : user.email
end