Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

topcoder-archive/appirio_tech-ng-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6c39a80 · Mar 28, 2016
Mar 22, 2016
Mar 28, 2016
Mar 17, 2016
Mar 22, 2016
Dec 18, 2015
Jan 12, 2016
Aug 20, 2015
Mar 22, 2016
Jan 4, 2016

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