Skip to content

appirio-tech/ng-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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