appirio-tech-ng-auth

[![GitHub version](https://badge.fury.io/gh/appirio-tech%2Fng-auth.svg)](http://badge.fury.io/gh/appirio-tech%2Fng-auth) [![Build Status](https://travis-ci.org/appirio-tech/ng-auth.svg)](https://travis-ci.org/appirio-tech/ng-auth) [![Coverage Status](http

Usage no npm install needed!

<script type="module">
  import appirioTechNgAuth from 'https://cdn.skypack.dev/appirio-tech-ng-auth';
</script>

README

ng-auth

GitHub version Build Status Coverage Status Dependency Status

Install

bower install appirio-tech-ng-auth=git@github.com:appirio-tech/ng-auth --save

Usage

Include source

<script src="/bower_components/appirio-tech-ng-auth/dist/main.js" type="text/javascript"></script>

Add dependency

'use strict'

dependencies = [
  'appirio-tech-ng-auth'
]

angular.module 'app', dependencies

Login via a controller

controller = -> ($scope, AuthService)
  onSuccess = ->
    console.log 'log in successful'

  onError = ->
    console.log 'log in failed'

  $scope.login = ->
    loginOptions =
      username: $scope.username
      password: $scope.password
      error: onError
      success: onSuccess

    AuthService.login loginOptions

Check if user is logged in

isLoggedIn = AuthService.isLoggedIn

Get current user


controller = -> ($scope, UserV3Service)
  vm = this
  scope.$watch UserV3Service.getCurrentUser, ->
    user = UserV3Service.getCurrentUser()
    vm.user = user if user