# Class User < ActiveRecord::Base

- app/models/user.rb

## Schema Information

Table name: users

    id                     :integer          not null, primary key
    email                  :string(255)      default(""), not null
    encrypted_password     :string(255)      default(""), not null
    reset_password_token   :string(255)
    reset_password_sent_at :datetime
    remember_created_at    :datetime
    sign_in_count          :integer          default(0)
    current_sign_in_at     :datetime
    last_sign_in_at        :datetime
    current_sign_in_ip     :string(255)
    last_sign_in_ip        :string(255)
    created_at             :datetime         not null
    updated_at             :datetime         not null
    name                   :string(255)
    admin                  :boolean          default(FALSE), not null
    projects_limit         :integer          default(10)
    skype                  :string(255)      default(""), not null
    linkedin               :string(255)      default(""), not null
    twitter                :string(255)      default(""), not null
    authentication_token   :string(255)
    dark_scheme            :boolean          default(FALSE), not null
    theme_id               :integer          default(1), not null
    bio                    :string(255)
    blocked                :boolean          default(FALSE), not null
    failed_attempts        :integer          default(0)
    locked_at              :datetime
    extern_uid             :string(255)
    provider               :string(255)
    username               :string(255)

Methods

C
  - create_from_omniauth
F
  - filter,
  - find_for_ldap_auth,
  - find_or_new_for_omniauth
G
  - generate_password,
  - gitlab_auth
N
  - not_in_project
S
  - search
W
  - without_projects

Included Modules

- Account

Attributes

[RW] | force_random_password |

Class Public methods
create_from_omniauth(auth, ldap = false) Link

Source: show

    # File app/models/user.rb, line 108
    def create_from_omniauth(auth, ldap = false)
      gitlab_auth.create_from_omniauth(auth, ldap)
    end

filter(filter_name) Link

Source: show

    # File app/models/user.rb, line 86
    def filter filter_name
      case filter_name
      when "admins"; self.admins
      when "blocked"; self.blocked
      when "wop"; self.without_projects
      else
        self.active
      end
    end

find_for_ldap_auth(auth, signed_in_resource = nil) Link

Source: show

    # File app/models/user.rb, line 116
    def find_for_ldap_auth(auth, signed_in_resource = nil)
      gitlab_auth.find_for_ldap_auth(auth, signed_in_resource)
    end

find_or_new_for_omniauth(auth) Link

Source: show

    # File app/models/user.rb, line 112
    def find_or_new_for_omniauth(auth)
      gitlab_auth.find_or_new_for_omniauth(auth)
    end

gitlab_auth() Link

Source: show

    # File app/models/user.rb, line 120
    def gitlab_auth
      Gitlab::Auth.new
    end

not_in_project(project) Link

Source: show

    # File app/models/user.rb, line 96
    def not_in_project(project)
      if project.users.present?
        where("id not in (:ids)", ids: project.users.map(&:id) )
      else
        scoped
      end
    end

search(query) Link

Source: show

    # File app/models/user.rb, line 124
    def search query
      where("name LIKE :query or email LIKE :query", query: "%#{query}%")
    end

without_projects() Link

Source: show

    # File app/models/user.rb, line 104
    def without_projects
      where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)')
    end

Instance Public methods
generate_password() Link

Source: show

    # File app/models/user.rb, line 129
    def generate_password
      if self.force_random_password
        self.password = self.password_confirmation = Devise.friendly_token.first(8)
      end
    end