Class: AnonymousUser

Inherits:
User show all
Defined in:
app/models/anonymous_user.rb

Overview

Redmine - project management software Copyright © 2006-2022 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Constant Summary

Constants inherited from User

User::LABEL_BY_STATUS, User::LOGIN_LENGTH_LIMIT, User::MAIL_LENGTH_LIMIT, User::MAIL_NOTIFICATION_OPTIONS, User::USER_FORMATS

Constants inherited from Principal

Principal::STATUS_ACTIVE, Principal::STATUS_ANONYMOUS, Principal::STATUS_LOCKED, Principal::STATUS_REGISTERED

Instance Attribute Summary

Attributes inherited from User

#generate_password, #last_before_login_on, #password, #password_confirmation, #remote_ip

Instance Method Summary collapse

Methods inherited from User

#activate, #activate!, #active?, #allowed_to?, #allowed_to_globally?, #allowed_to_view_all_time_entries?, anonymous, #anonymous?, #api_key, #base_reload, #bookmarked_project_ids, #change_password_allowed?, #check_password?, #convert_time_to_user_timezone, #css_classes, current, current=, default_admin_account_changed?, #delete_autologin_token, #delete_session_token, fields_for_order_statement, find_by_api_key, find_by_login, find_by_mail, find_by_rss_key, #force_default_language?, #generate_autologin_token, #generate_password?, generate_salt, #generate_session_token, hash_password, #is_or_belongs_to?, #language, #lock, #lock!, #locked?, #mail_changed?, #mails, #managed_roles, #must_activate_twofa?, #must_change_password?, name_formatter, #notified_project_ids=, #notified_projects_ids, #notify_about?, #notify_about_high_priority_issues?, #own_account_deletable?, #password_expired?, #project_ids_by_role, #projects_by_role, #random_password, #register, #register!, #registered?, #reload, #roles, #roles_for_project, #salt_password, salt_unsalted_passwords!, #set_mail_notification, #time_to_date, #to_s, #today, try_to_autologin, try_to_login, try_to_login!, #twofa_active?, #twofa_totp_key, #twofa_totp_key=, #update_hashed_password, #update_last_login_on!, valid_notification_options, #valid_notification_options, verify_session_token, #visible_project_ids, #wants_comments_in_reverse_order?

Methods included from Redmine::SafeAttributes

#delete_unsafe_attributes, included, #safe_attribute?, #safe_attribute_names, #safe_attributes=

Methods included from Redmine::Ciphering

cipher_key, decrypt_text, encrypt_text, included, logger

Methods inherited from Principal

#<=>, detect_by_keyword, fields_for_order_statement, #nullify_projects_default_assigned_to, #project_ids, #reload, #visible?

Instance Method Details

#adminObject



36
# File 'app/models/anonymous_user.rb', line 36

def admin; false end

#available_custom_fieldsObject



30
31
32
# File 'app/models/anonymous_user.rb', line 30

def available_custom_fields
  []
end

#builtin_roleObject

Returns the user’s bult-in role



48
49
50
# File 'app/models/anonymous_user.rb', line 48

def builtin_role
  @builtin_role ||= Role.anonymous
end

#destroyObject

Anonymous user can not be destroyed



61
62
63
# File 'app/models/anonymous_user.rb', line 61

def destroy
  false
end

#logged?Boolean

Overrides a few properties

Returns:

  • (Boolean)


35
# File 'app/models/anonymous_user.rb', line 35

def logged?; false end

#mailObject



39
# File 'app/models/anonymous_user.rb', line 39

def mail; nil end

#mail=(*args) ⇒ Object



38
# File 'app/models/anonymous_user.rb', line 38

def mail=(*args); nil end

#member_of?(*args) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/models/anonymous_user.rb', line 56

def member_of?(*args)
  false
end

#membership(*args) ⇒ Object



52
53
54
# File 'app/models/anonymous_user.rb', line 52

def membership(*args)
  nil
end

#name(*args) ⇒ Object



37
# File 'app/models/anonymous_user.rb', line 37

def name(*args); I18n.t(:label_user_anonymous) end

#prefObject



43
44
45
# File 'app/models/anonymous_user.rb', line 43

def pref
  UserPreference.new(:user => self)
end

#rss_keyObject



41
# File 'app/models/anonymous_user.rb', line 41

def rss_key; nil end

#time_zoneObject



40
# File 'app/models/anonymous_user.rb', line 40

def time_zone; nil end

#validate_anonymous_uniquenessObject



25
26
27
28
# File 'app/models/anonymous_user.rb', line 25

def validate_anonymous_uniqueness
  # There should be only one AnonymousUser in the database
  errors.add :base, 'An anonymous user already exists.' if AnonymousUser.unscoped.exists?
end