Check if logged before checking admin

This commit is contained in:
Josef Citrine 2016-05-17 12:59:46 +01:00
parent 40122a9446
commit 7bc8852043

View file

@ -17,7 +17,7 @@
module.exports = angular.module('ponyfm').factory('auth', [
'$rootScope'
($rootScope) ->
data: {isLogged: window.pfm.auth.isLogged, user: window.pfm.auth.user, isAdmin: (window.pfm.auth.user.roles[0] && window.pfm.auth.user.roles[0].id == 2)}
data: {isLogged: window.pfm.auth.isLogged, user: window.pfm.auth.user, isAdmin: (window.pfm.auth.isLogged && window.pfm.auth.user.roles[0] && window.pfm.auth.user.roles[0].id == 2)}
login: (email, password, remember) ->
def = new $.Deferred()
$.post('/api/web/auth/login', {email: email, password: password, remember: remember})