Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've written an <a href="https://github.com/userapp-io/userapp-angular" rel="noreferrer">AngularJS module</a> for <a href="https://www.userapp.io/" rel="noreferrer">UserApp</a> that does pretty much everything you ask for. You could either:</p> <ol> <li>Modify the module and attach the functions to your own API, or </li> <li>Use the module together with the user management API, <a href="https://www.userapp.io/" rel="noreferrer">UserApp</a></li> </ol> <p><a href="https://github.com/userapp-io/userapp-angular" rel="noreferrer">https://github.com/userapp-io/userapp-angular</a></p> <p>It supports protected/public routes, rerouting on login/logout, heartbeats for status checks, stores the session token in a cookie, events, etc. </p> <p>If you want to give UserApp a try, take the <a href="http://www.codecademy.com/courses/web-beginner-en-v2b3k" rel="noreferrer">course on Codecademy</a>.</p> <p>Here's some examples of how it works:</p> <ul> <li><p><strong>Login form with error handling:</strong></p> <pre><code>&lt;form ua-login ua-error="error-msg"&gt; &lt;input name="login" placeholder="Username"&gt;&lt;br&gt; &lt;input name="password" placeholder="Password" type="password"&gt;&lt;br&gt; &lt;button type="submit"&gt;Log in&lt;/button&gt; &lt;p id="error-msg"&gt;&lt;/p&gt; &lt;/form&gt; </code></pre></li> <li><p><strong>Signup form with error handling:</strong></p> <pre><code>&lt;form ua-signup ua-error="error-msg"&gt; &lt;input name="first_name" placeholder="Your name"&gt;&lt;br&gt; &lt;input name="login" ua-is-email placeholder="Email"&gt;&lt;br&gt; &lt;input name="password" placeholder="Password" type="password"&gt;&lt;br&gt; &lt;button type="submit"&gt;Create account&lt;/button&gt; &lt;p id="error-msg"&gt;&lt;/p&gt; &lt;/form&gt; </code></pre></li> <li><p><strong>How to specify which routes that should be public, and which route that is the login form:</strong></p> <pre><code>$routeProvider.when('/login', {templateUrl: 'partials/login.html', public: true, login: true}); $routeProvider.when('/signup', {templateUrl: 'partials/signup.html', public: true}); </code></pre> <p>The <code>.otherwise()</code> route should be set to where you want your users to be redirected after login. Example:</p> <p><code>$routeProvider.otherwise({redirectTo: '/home'});</code></p></li> <li><p><strong>Log out link:</strong></p> <p><code>&lt;a href="#" ua-logout&gt;Log Out&lt;/a&gt;</code></p> <p>(Ends the session and redirects to the login route)</p></li> <li><p><strong>Access user properties:</strong></p> <p>User info is accessed using the <code>user</code> service, e.g: <code>user.current.email</code></p> <p>Or in the template: <code>&lt;span&gt;{{ user.email }}&lt;/span&gt;</code></p></li> <li><p><strong>Hide elements that should only be visible when logged in:</strong></p> <p><code>&lt;div ng-show="user.authorized"&gt;Welcome {{ user.first_name }}!&lt;/div&gt;</code></p></li> <li><p><strong>Show an element based on permissions:</strong></p> <p><code>&lt;div ua-has-permission="admin"&gt;You are an admin&lt;/div&gt;</code></p></li> </ul> <p>And to authenticate to your back-end services, just use <code>user.token()</code> to get the session token and send it with the AJAX request. At the back-end, use the <a href="https://app.userapp.io/#/docs/" rel="noreferrer">UserApp API</a> (if you use UserApp) to check if the token is valid or not.</p> <p>If you need any help, just let me know :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload