userapp-angular

AngularJS module that adds user authentication to your app with UserApp.
Homepage: https://userapp.io
4 people use it
Author: Ec8c9beef8a9a131f4b15a61b7bdac0d?d=https%3a%2f%2fidenticons.github.com%2fdc8edbcc51ed8d5669ea51b93bbdb88c userapp-io
Submitted by: 6027bdc0a63b14a5c51b5a48a31cb5dc?d=https%3a%2f%2fidenticons.github.com%2f2cb5cf8fcea69c3a4b639c19880b1a07 timothyej

UserApp AngularJS

AngularJS module that adds user authentication to your app with UserApp. It supports protected/public routes, rerouting on login/logout, heartbeats for status checks, stores the session token in a cookie, directives for signup/login/logout, etc.

UserApp is a cloud-based user management API for web apps with the purpose to relieve developers from having to program logic for user authentication, sign-up, invoicing, feature/property/permission management, and more.

Getting Started

Take the course on Codecademy

or

  1. Include the UserApp JavaScript library and this AngularJS module in your index.html.

  2. Inject and initiate the service in your root scope with your App Id:

  3. Create routes + templates for login and signup, and use the directives to connect them to UserApp (examples: login.html and signup.html):

  4. Set public to true on the routes you want to make public. And set login to true on the login route:

    The .otherwise() route should be set to where you want your users to be redirected after login. Example:

  5. Add a log out link:

    (End the session and redirects to the login route)

  6. Hide elements that should only be visible when logged in:

  7. Use the user object to access properties on the logged in user:

  8. Read this documention and the UserApp Documentation to learn how to use the full API!

Services

user

The main service with all session handling etc.

  • user.init(config)

    Initiate the service with your App Id.

  • user.status()

    Returns the status of the session:

  • user.appId([value])

    Sets and gets the App Id.

  • user.token([value])

    Sets and gets the session token (stored in a cookie).

  • user.current

    The logged in user. See User documentation for more info.

  • user.signup(user[, callback])

    Sign up a user, log in, and redirect to default route.

  • user.login(user[, callback])

    Log in a user and redirect to default route.

  • user.logout([callback])

    Log out the logged in user and redirect to the log in route.

  • user.hasPermission(permissions)

    Returns true if the user has all the permissions in the string or array permissions. Else it returns false.

  • user.hasFeature(features)

    Returns true if the user has all the features in the string or array features. Else it returns false.

UserApp

Exposes the full UserApp API with the JavaScript library.

Directives

  • ua-login

    Add this to a form tag to attach it to the user.login() function. Use ua-error to specify an error object.

  • ua-logout

    Add this to a log out link to attach it to the user.logout() function.

  • ua-signup

    Add this to a form tag to attach it to the user.signup() function. Use ua-error to specify an error object. Use ua-is-email on the login input to specify that login is the same as email. All input field names must reflect the user's properties.

  • ua-has-permission="permissions"

    Add this to an element to attach it to the user.hasPermission() function. The element will be hidden if not all permissions are true. Multiple permissions are separated with whitespace.

  • ua-has-feature="features"

    Add this to an element to attach it to the user.hasFeature() function. The element will be hidden if not all features are true. Multiple features are separated with whitespace.

Events

  • user.login

    Event triggered when user logs in

  • user.logout

    Event triggered when user logs out

Example

See example/ for a demo app based on angular-seed.

Help

Contact us via email at support@userapp.io or visit our support center.

License

MIT, see LICENSE.

comments powered by Disqus
This page was last updated almost 4 years ago.