UNPKG

periodicjs.ext.login

Version:

An authentication extension for periodicjs that uses passport to authenticate user sessions.

807 lines (278 loc) 11.6 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Module: authController</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Module: authController</h1> <section> <header> <h2> authController </h2> </header> <article> <div class="container-overview"> <div class="description"><p>login controller</p></div> <dl class="details"> <dt class="tag-author">Author:</dt> <dd class="tag-author"> <ul> <li>Yaw Joseph Etse</li> </ul> </dd> <dt class="tag-copyright">Copyright:</dt> <dd class="tag-copyright"><ul class="dummy"><li>Copyright (c) 2014 Typesettin. All rights reserved.</li></ul></dd> <dt class="tag-license">License:</dt> <dd class="tag-license"><ul class="dummy"><li>MIT</li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="auth.js.html">controller/auth.js</a>, <a href="auth.js.html#line168">line 168</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Requires</h3> <ul> <li>module:passport</li> <li>module:path</li> <li>module:passport-local</li> <li>module:passport-facebook</li> <li>module:fs-extra</li> <li>module:periodicjs.core.utilities</li> <li>module:periodicjs.core.controller</li> <li>module:periodicjs.core.extensions</li> </ul> <h3 class="subsection-title">Methods</h3> <dl> <dt> <h4 class="name" id="ensureAuthenticated"><span class="type-signature">&lt;inner> </span>ensureAuthenticated<span class="signature">(req, res)</span><span class="type-signature"> &rarr; {function}</span></h4> </dt> <dd> <div class="description"> <p>make sure a user is authenticated, if not logged in, send them to login page and return them to original resource after login</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>req</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>res</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="auth.js.html">controller/auth.js</a>, <a href="auth.js.html#line96">line 96</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>next() callback</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">function</span> </dd> </dl> </dd> <dt> <h4 class="name" id="login"><span class="type-signature">&lt;inner> </span>login<span class="signature">(req, res)</span><span class="type-signature"> &rarr; {object}</span></h4> </dt> <dd> <div class="description"> <p>logins a user using passport's local strategy, if a user is passed to this function, then the user will be logged in and req.user will be populated</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>req</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>res</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="auth.js.html">controller/auth.js</a>, <a href="auth.js.html#line23">line 23</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>reponds with an error page or sends user to authenicated in resource</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="logout"><span class="type-signature">&lt;inner> </span>logout<span class="signature">(req, res)</span><span class="type-signature"> &rarr; {object}</span></h4> </dt> <dd> <div class="description"> <p>logs user out and destroys user session</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>req</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>res</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="auth.js.html">controller/auth.js</a>, <a href="auth.js.html#line60">line 60</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>sends user to logout resource</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> </dd> <dt> <h4 class="name" id="rememberme"><span class="type-signature">&lt;inner> </span>rememberme<span class="signature">(req, res)</span><span class="type-signature"> &rarr; {function}</span></h4> </dt> <dd> <div class="description"> <p>keep a user logged in for 30 days</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>req</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>res</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="auth.js.html">controller/auth.js</a>, <a href="auth.js.html#line76">line 76</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>next() callback</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">function</span> </dd> </dl> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-authController.html">authController</a></li><li><a href="module-userloginController.html">userloginController</a></li><li><a href="login.html">login</a></li></ul><h3>Global</h3><ul><li><a href="global.html#facebook">facebook</a></li><li><a href="global.html#facebookcallback">facebookcallback</a></li><li><a href="global.html#instagram">instagram</a></li><li><a href="global.html#instagramcallback">instagramcallback</a></li><li><a href="global.html#saveUser">saveUser</a></li><li><a href="global.html#twitter">twitter</a></li><li><a href="global.html#twittercallback">twittercallback</a></li><li><a href="global.html#usePassport">usePassport</a></li></ul> </nav> <br clear="both"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Thu Jan 29 2015 21:18:44 GMT-0500 (EST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>