Adding some documentation.
[lyrix.git] / doc / app / classes / SessionsController.html
bloba98a459a9bb3b26ccf49dc20b3b06df282073820
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE html
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <title>Class: SessionsController</title>
9 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10 <meta http-equiv="Content-Script-Type" content="text/javascript" />
11 <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12 <script type="text/javascript">
13 // <![CDATA[
15 function popupCode( url ) {
16 window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
19 function toggleCode( id ) {
20 if ( document.getElementById )
21 elem = document.getElementById( id );
22 else if ( document.all )
23 elem = eval( "document.all." + id );
24 else
25 return false;
27 elemStyle = elem.style;
29 if ( elemStyle.display != "block" ) {
30 elemStyle.display = "block"
31 } else {
32 elemStyle.display = "none"
35 return true;
38 // Make codeblocks hidden by default
39 document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
41 // ]]>
42 </script>
44 </head>
45 <body>
49 <div id="classHeader">
50 <table class="header-table">
51 <tr class="top-aligned-row">
52 <td><strong>Class</strong></td>
53 <td class="class-name-in-header">SessionsController</td>
54 </tr>
55 <tr class="top-aligned-row">
56 <td><strong>In:</strong></td>
57 <td>
58 <a href="../files/app/controllers/sessions_controller_rb.html">
59 app/controllers/sessions_controller.rb
60 </a>
61 <br />
62 </td>
63 </tr>
65 <tr class="top-aligned-row">
66 <td><strong>Parent:</strong></td>
67 <td>
68 <a href="ApplicationController.html">
69 ApplicationController
70 </a>
71 </td>
72 </tr>
73 </table>
74 </div>
75 <!-- banner header -->
77 <div id="bodyContent">
81 <div id="contextContent">
83 <div id="description">
84 <p>
85 This controller handles the login/logout function of the site.
86 </p>
88 </div>
91 </div>
93 <div id="method-list">
94 <h3 class="section-bar">Methods</h3>
96 <div class="name-list">
97 <a href="#M000009">create</a>&nbsp;&nbsp;
98 <a href="#M000010">destroy</a>&nbsp;&nbsp;
99 <a href="#M000008">new</a>&nbsp;&nbsp;
100 </div>
101 </div>
103 </div>
106 <!-- if includes -->
108 <div id="section">
117 <!-- if method_list -->
118 <div id="methods">
119 <h3 class="section-bar">Public Instance methods</h3>
121 <div id="method-M000009" class="method-detail">
122 <a name="M000009"></a>
124 <div class="method-heading">
125 <a href="#M000009" class="method-signature">
126 <span class="method-name">create</span><span class="method-args">()</span>
127 </a>
128 </div>
130 <div class="method-description">
132 Actually log the person into the system
133 </p>
135 This handles verification of the user&#8217;s credentials, along with
136 creating a cookie for Remember Me.
137 </p>
138 <p><a class="source-toggle" href="#"
139 onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
140 <div class="method-source-code" id="M000009-source">
141 <pre>
142 <span class="ruby-comment cmt"># File app/controllers/sessions_controller.rb, line 12</span>
143 12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>
144 13: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current_user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">authenticate</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:login</span>], <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:password</span>])
145 14: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logged_in?</span>
146 15: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:remember_me</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;1&quot;</span>
147 16: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">remember_me</span>
148 17: <span class="ruby-identifier">cookies</span>[<span class="ruby-identifier">:auth_token</span>] = { <span class="ruby-identifier">:value</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">remember_token</span> , <span class="ruby-identifier">:expires</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">remember_token_expires_at</span> }
149 18: <span class="ruby-keyword kw">end</span>
150 19: <span class="ruby-identifier">redirect_back_or_default</span>(<span class="ruby-value str">'/'</span>)
151 20: <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">&quot;Logged in successfully&quot;</span>
152 21: <span class="ruby-keyword kw">else</span>
153 22: <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'new'</span>
154 23: <span class="ruby-keyword kw">end</span>
155 24: <span class="ruby-keyword kw">end</span>
156 </pre>
157 </div>
158 </div>
159 </div>
161 <div id="method-M000010" class="method-detail">
162 <a name="M000010"></a>
164 <div class="method-heading">
165 <a href="#M000010" class="method-signature">
166 <span class="method-name">destroy</span><span class="method-args">()</span>
167 </a>
168 </div>
170 <div class="method-description">
172 Kills the session.
173 </p>
174 <p><a class="source-toggle" href="#"
175 onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
176 <div class="method-source-code" id="M000010-source">
177 <pre>
178 <span class="ruby-comment cmt"># File app/controllers/sessions_controller.rb, line 27</span>
179 27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">destroy</span>
180 28: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">forget_me</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logged_in?</span>
181 29: <span class="ruby-identifier">cookies</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">:auth_token</span>
182 30: <span class="ruby-identifier">reset_session</span>
183 31: <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">&quot;You have been logged out.&quot;</span>
184 32: <span class="ruby-identifier">redirect_back_or_default</span>(<span class="ruby-value str">'/'</span>)
185 33: <span class="ruby-keyword kw">end</span>
186 </pre>
187 </div>
188 </div>
189 </div>
191 <div id="method-M000008" class="method-detail">
192 <a name="M000008"></a>
194 <div class="method-heading">
195 <a href="#M000008" class="method-signature">
196 <span class="method-name">new</span><span class="method-args">()</span>
197 </a>
198 </div>
200 <div class="method-description">
202 This is the login form page
203 </p>
204 <p><a class="source-toggle" href="#"
205 onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
206 <div class="method-source-code" id="M000008-source">
207 <pre>
208 <span class="ruby-comment cmt"># File app/controllers/sessions_controller.rb, line 6</span>
209 6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new</span>; <span class="ruby-keyword kw">end</span>
210 </pre>
211 </div>
212 </div>
213 </div>
216 </div>
219 </div>
222 <div id="validator-badges">
223 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
224 </div>
226 </body>
227 </html>