balena-cli/doc/file/lib/resin/auth/auth.coffee.html
2014-12-09 12:47:43 -04:00

466 lines
11 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>CoffeeScript API Documentation</title>
<script src='../../../../javascript/application.js'></script>
<script src='../../../../javascript/search.js'></script>
<link rel='stylesheet' href='../../../../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../../../../'></div>
<div id='header'>
<div id='menu'>
<a href='../../../../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>lib</span>
&raquo;
<span class='title'>resin</span>
&raquo;
<span class='title'>auth</span>
&raquo;
<span class='title'>auth.coffee</span>
</div>
</div>
<div id='content'>
<h1>
File:
auth.coffee
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;resin&#47;auth</td>
</tr>
</table>
<h2>Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#authenticate-'>
~
(void)
<b>authenticate</b><span>(credentials, callback)</span>
</a>
</span>
<span class='note private title'>Private</span>
<span class='desc'>
Authenticate with the server <pre><code>resin.auth.authenticate credentials, (error, token) -&gt; throw error if error? console.log(token)
</code></pre>
</span>
</li>
<li>
<span class='signature'>
<a href='#login-'>
~
(void)
<b>login</b><span>(credentials, callback)</span>
</a>
</span>
<span class='desc'>
Login to Resin.io <p>Is the login is successful, the token is persisted between sessions.</p>
</span>
</li>
<li>
<span class='signature'>
<a href='#isLoggedIn-'>
~
(void)
<b>isLoggedIn</b><span>(callback)</span>
</a>
</span>
<span class='desc'>
Check if you&#39;re logged in <pre><code>resin.auth.isLoggedIn (isLoggedIn) -&gt; if isLoggedIn
console.log(&#39;I\&#39;m in!&#39;) else
console.log(&#39;Too bad!&#39;)
</code></pre>
</span>
</li>
<li>
<span class='signature'>
<a href='#getToken-'>
~
(void)
<b>getToken</b><span>(callback)</span>
</a>
</span>
<span class='desc'>
Get current logged in user&#39;s token <pre><code>resin.auth.getToken (error, token) -&gt; throw error if error? console.log(token)
</code></pre>
</span>
</li>
<li>
<span class='signature'>
<a href='#logout-'>
~
(void)
<b>logout</b><span>(callback)</span>
</a>
</span>
<span class='desc'>
Logout from Resin.io <pre><code>resin.auth.logout (error) -&gt; throw error if error? console.log(&#39;I\&#39;m out!&#39;)
</code></pre>
</span>
</li>
<li>
<span class='signature'>
<a href='#parseCredentials-'>
~
(void)
<b>parseCredentials</b><span>(credentials, callback)</span>
</a>
</span>
<span class='note private title'>Private</span>
<span class='desc'>
Parse colon separated credentials <pre><code>resin.auth.parseCredentials &#39;johndoe:secret&#39;, (error, credentials) -&gt; throw error if error? console.log(credentials.username) console.log(credentials.password)
</code></pre>
</span>
</li>
</ul>
<h2>Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='authenticate-'>
~
(void)
<b>authenticate</b><span>(credentials, callback)</span>
<span class='note private'>Private</span>
<br>
</p>
<div class='docstring'>
<div class='note'>
<strong>Note:</strong>
You should use login() when possible, as it takes care of saving the token as well.
</div>
<p>Authenticate with the server</p><pre><code>resin.auth.authenticate credentials, (error, token) -&gt; throw error if error? console.log(token)
</code></pre>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>credentials</span>
<span class='type'>
(
<tt>Object</tt>
)
</span>
&mdash;
<span class='desc'>in the form of username, password </span>
</li>
<li>
<span class='name'>callback</span>
<span class='type'>
(
<tt>Function</tt>
)
</span>
&mdash;
<span class='desc'>callback (error, token) </span>
</li>
</ul>
<h3>
Options Hash:
(credentials):
</h3>
<ul class='options'>
<li>
<span class='name'>username</span>
<span class='type'>
(
<tt>String</tt>
)
</span>
&mdash;
<span class='desc'>the username </span>
</li>
<li>
<span class='name'>password</span>
<span class='type'>
(
<tt>String</tt>
)
</span>
&mdash;
<span class='desc'>user password </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='login-'>
~
(void)
<b>login</b><span>(credentials, callback)</span>
<br>
</p>
<div class='docstring'>
<div class='note'>
<strong>Note:</strong>
This function saves the token to the directory configured in dataPrefix
</div>
<p>Login to Resin.io</p><p>Is the login is successful, the token is persisted between sessions.</p><pre><code>resin.auth.login credentials, (error) -&gt; throw error if error? console.log(&#39;I\&#39;m logged in!&#39;)
</code></pre>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>credentials</span>
<span class='type'>
(
<tt>Object</tt>
)
</span>
&mdash;
<span class='desc'>in the form of username, password </span>
</li>
<li>
<span class='name'>callback</span>
<span class='type'>
(
<tt>Function</tt>
)
</span>
&mdash;
<span class='desc'>callback (error) </span>
</li>
</ul>
<h3>
Options Hash:
(credentials):
</h3>
<ul class='options'>
<li>
<span class='name'>username</span>
<span class='type'>
(
<tt>String</tt>
)
</span>
&mdash;
<span class='desc'>the username </span>
</li>
<li>
<span class='name'>password</span>
<span class='type'>
(
<tt>String</tt>
)
</span>
&mdash;
<span class='desc'>user password </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='isLoggedIn-'>
~
(void)
<b>isLoggedIn</b><span>(callback)</span>
<br>
</p>
<div class='docstring'>
<p>Check if you&#39;re logged in</p><pre><code>resin.auth.isLoggedIn (isLoggedIn) -&gt; if isLoggedIn
console.log(&#39;I\&#39;m in!&#39;) else
console.log(&#39;Too bad!&#39;)
</code></pre>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>callback</span>
<span class='type'>
(
<tt>Function</tt>
)
</span>
&mdash;
<span class='desc'>callback (isLoggedIn) </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='getToken-'>
~
(void)
<b>getToken</b><span>(callback)</span>
<br>
</p>
<div class='docstring'>
<div class='note'>
<strong>Note:</strong>
This function simply delegates to resin.token.getToken() for convenience
</div>
<p>Get current logged in user&#39;s token</p><pre><code>resin.auth.getToken (error, token) -&gt; throw error if error? console.log(token)
</code></pre>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>callback</span>
<span class='type'>
(
<tt>Function</tt>
)
</span>
&mdash;
<span class='desc'>callback (error, isLoggedIn) </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='logout-'>
~
(void)
<b>logout</b><span>(callback)</span>
<br>
</p>
<div class='docstring'>
<div class='note todo'>
<strong>TODO:</strong>
Maybe we should post to /logout or something to invalidate the token on the server?
</div>
<p>Logout from Resin.io</p><pre><code>resin.auth.logout (error) -&gt; throw error if error? console.log(&#39;I\&#39;m out!&#39;)
</code></pre>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>callback</span>
<span class='type'>
(
<tt>Function</tt>
)
</span>
&mdash;
<span class='desc'>callback (error) </span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='parseCredentials-'>
~
(void)
<b>parseCredentials</b><span>(credentials, callback)</span>
<span class='note private'>Private</span>
<br>
</p>
<div class='docstring'>
<div class='note todo'>
<strong>TODO:</strong>
This should be moved somewhere else, as it only used by the auth actions
</div>
<p>Parse colon separated credentials</p><pre><code>resin.auth.parseCredentials &#39;johndoe:secret&#39;, (error, credentials) -&gt; throw error if error? console.log(credentials.username) console.log(credentials.password)
</code></pre>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>colon</span>
<span class='type'>
(
<tt>String</tt>
)
</span>
&mdash;
<span class='desc'>separated credentials (username:password) </span>
</li>
<li>
<span class='name'>callback</span>
<span class='type'>
(
<tt>Function</tt>
)
</span>
&mdash;
<span class='desc'>callback (error, credentials) </span>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id='footer'>
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>