<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>User</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" /> <link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" /> <link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" /> <script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script> <script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script> <script src="../js/main.js" type="text/javascript" charset="utf-8"></script> <script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script> </head> <body> <div class="banner"> <h1> <span class="type">Class</span> User <span class="parent">< ActiveRecord::Base </span> </h1> <ul class="files"> <li><a href="../files/app/models/user_rb.html">app/models/user.rb</a></li> </ul> </div> <div id="bodyContent"> <div id="content"> <div class="description"> <h2 id="label-Schema+Information">Schema Information</h2> <p>Table name: users</p> <pre>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)</pre> </div> <!-- Method ref --> <div class="sectiontitle">Methods</div> <dl class="methods"> <dt>C</dt> <dd> <ul> <li> <a href="#method-c-create_from_omniauth">create_from_omniauth</a> </li> </ul> </dd> <dt>F</dt> <dd> <ul> <li> <a href="#method-c-filter">filter</a>, </li> <li> <a href="#method-c-find_for_ldap_auth">find_for_ldap_auth</a>, </li> <li> <a href="#method-c-find_or_new_for_omniauth">find_or_new_for_omniauth</a> </li> </ul> </dd> <dt>G</dt> <dd> <ul> <li> <a href="#method-i-generate_password">generate_password</a>, </li> <li> <a href="#method-c-gitlab_auth">gitlab_auth</a> </li> </ul> </dd> <dt>N</dt> <dd> <ul> <li> <a href="#method-c-not_in_project">not_in_project</a> </li> </ul> </dd> <dt>S</dt> <dd> <ul> <li> <a href="#method-c-search">search</a> </li> </ul> </dd> <dt>W</dt> <dd> <ul> <li> <a href="#method-c-without_projects">without_projects</a> </li> </ul> </dd> </dl> <!-- Includes --> <div class="sectiontitle">Included Modules</div> <ul> <li> <a href="Account.html"> Account </a> </li> </ul> <!-- Section attributes --> <div class="sectiontitle">Attributes</div> <table border='0' cellpadding='5'> <tr valign='top'> <td class='attr-rw'> [RW] </td> <td class='attr-name'>force_random_password</td> <td class='attr-desc'></td> </tr> </table> <!-- Methods --> <div class="sectiontitle">Class Public methods</div> <div class="method"> <div class="title method-title" id="method-c-create_from_omniauth"> <b>create_from_omniauth</b>(auth, ldap = false) <a href="../classes/User.html#method-c-create_from_omniauth" name="method-c-create_from_omniauth" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-create_from_omniauth_source')" id="l_method-c-create_from_omniauth_source">show</a> </p> <div id="method-c-create_from_omniauth_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 108</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">create_from_omniauth</span>(<span class="ruby-identifier">auth</span>, <span class="ruby-identifier">ldap</span> = <span class="ruby-keyword">false</span>) <span class="ruby-identifier">gitlab_auth</span>.<span class="ruby-identifier">create_from_omniauth</span>(<span class="ruby-identifier">auth</span>, <span class="ruby-identifier">ldap</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="method"> <div class="title method-title" id="method-c-filter"> <b>filter</b>(filter_name) <a href="../classes/User.html#method-c-filter" name="method-c-filter" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-filter_source')" id="l_method-c-filter_source">show</a> </p> <div id="method-c-filter_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 86</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">filter</span> <span class="ruby-identifier">filter_name</span> <span class="ruby-keyword">case</span> <span class="ruby-identifier">filter_name</span> <span class="ruby-keyword">when</span> <span class="ruby-string">"admins"</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">admins</span> <span class="ruby-keyword">when</span> <span class="ruby-string">"blocked"</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">blocked</span> <span class="ruby-keyword">when</span> <span class="ruby-string">"wop"</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">without_projects</span> <span class="ruby-keyword">else</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">active</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="method"> <div class="title method-title" id="method-c-find_for_ldap_auth"> <b>find_for_ldap_auth</b>(auth, signed_in_resource = nil) <a href="../classes/User.html#method-c-find_for_ldap_auth" name="method-c-find_for_ldap_auth" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-find_for_ldap_auth_source')" id="l_method-c-find_for_ldap_auth_source">show</a> </p> <div id="method-c-find_for_ldap_auth_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 116</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">find_for_ldap_auth</span>(<span class="ruby-identifier">auth</span>, <span class="ruby-identifier">signed_in_resource</span> = <span class="ruby-keyword">nil</span>) <span class="ruby-identifier">gitlab_auth</span>.<span class="ruby-identifier">find_for_ldap_auth</span>(<span class="ruby-identifier">auth</span>, <span class="ruby-identifier">signed_in_resource</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="method"> <div class="title method-title" id="method-c-find_or_new_for_omniauth"> <b>find_or_new_for_omniauth</b>(auth) <a href="../classes/User.html#method-c-find_or_new_for_omniauth" name="method-c-find_or_new_for_omniauth" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-find_or_new_for_omniauth_source')" id="l_method-c-find_or_new_for_omniauth_source">show</a> </p> <div id="method-c-find_or_new_for_omniauth_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 112</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">find_or_new_for_omniauth</span>(<span class="ruby-identifier">auth</span>) <span class="ruby-identifier">gitlab_auth</span>.<span class="ruby-identifier">find_or_new_for_omniauth</span>(<span class="ruby-identifier">auth</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="method"> <div class="title method-title" id="method-c-gitlab_auth"> <b>gitlab_auth</b>() <a href="../classes/User.html#method-c-gitlab_auth" name="method-c-gitlab_auth" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-gitlab_auth_source')" id="l_method-c-gitlab_auth_source">show</a> </p> <div id="method-c-gitlab_auth_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 120</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">gitlab_auth</span> <span class="ruby-constant">Gitlab</span><span class="ruby-operator">::</span><span class="ruby-constant">Auth</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="method"> <div class="title method-title" id="method-c-not_in_project"> <b>not_in_project</b>(project) <a href="../classes/User.html#method-c-not_in_project" name="method-c-not_in_project" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-not_in_project_source')" id="l_method-c-not_in_project_source">show</a> </p> <div id="method-c-not_in_project_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 96</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">not_in_project</span>(<span class="ruby-identifier">project</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">users</span>.<span class="ruby-identifier">present?</span> <span class="ruby-identifier">where</span>(<span class="ruby-string">"id not in (:ids)"</span>, <span class="ruby-identifier">ids</span><span class="ruby-operator">:</span> <span class="ruby-identifier">project</span>.<span class="ruby-identifier">users</span>.<span class="ruby-identifier">map</span>(&<span class="ruby-value">:id</span>) ) <span class="ruby-keyword">else</span> <span class="ruby-identifier">scoped</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="method"> <div class="title method-title" id="method-c-search"> <b>search</b>(query) <a href="../classes/User.html#method-c-search" name="method-c-search" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-search_source')" id="l_method-c-search_source">show</a> </p> <div id="method-c-search_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 124</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">search</span> <span class="ruby-identifier">query</span> <span class="ruby-identifier">where</span>(<span class="ruby-string">"name LIKE :query or email LIKE :query"</span>, <span class="ruby-identifier">query</span><span class="ruby-operator">:</span> <span class="ruby-node">"%#{query}%"</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="method"> <div class="title method-title" id="method-c-without_projects"> <b>without_projects</b>() <a href="../classes/User.html#method-c-without_projects" name="method-c-without_projects" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-c-without_projects_source')" id="l_method-c-without_projects_source">show</a> </p> <div id="method-c-without_projects_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 104</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">without_projects</span> <span class="ruby-identifier">where</span>(<span class="ruby-string">'id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)'</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div class="sectiontitle">Instance Public methods</div> <div class="method"> <div class="title method-title" id="method-i-generate_password"> <b>generate_password</b>() <a href="../classes/User.html#method-i-generate_password" name="method-i-generate_password" class="permalink">Link</a> </div> <div class="description"> </div> <div class="sourcecode"> <p class="source-link"> Source: <a href="javascript:toggleSource('method-i-generate_password_source')" id="l_method-i-generate_password_source">show</a> </p> <div id="method-i-generate_password_source" class="dyn-source"> <pre><span class="ruby-comment"># File app/models/user.rb, line 129</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">generate_password</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">force_random_password</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">password</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">password_confirmation</span> = <span class="ruby-constant">Devise</span>.<span class="ruby-identifier">friendly_token</span>.<span class="ruby-identifier">first</span>(<span class="ruby-number">8</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> </div> </div> </body> </html>