Created
June 20, 2017 13:50
-
-
Save felisio/3457eebee4d5ca51868bec33219b0dce to your computer and use it in GitHub Desktop.
esqueleto do service para angular 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* servicos para o site | |
*/ | |
var $service = angular.module('app.services', []); | |
//-----------processo de Autenticação do usuario ----------------------------------// | |
//Factory para autenticação | |
$service.factory('AuthService', function ($rootScope, $http, Session) { | |
return { | |
login: function (user) { | |
//atraves do $HTTP - chamar metodo de login para os parametros | |
// se retornar com sucesso armazenar usuario no serviço Session que esta abaixo | |
} | |
}; | |
}); | |
// Service para guardar a sessão do usuario | |
$service.service('Session', function ($rootScope, $browser) { | |
this.create = function (sessionId, userId, userRole, user) { | |
this.id = sessionId; | |
this.userId = userId; | |
this.userRole = userRole; | |
this.user = user; | |
//TODO: falta implementar o armazenamento em LocalStorage | |
}; | |
this.destroy = function () { | |
this.id = null; | |
this.userId = null; | |
this.userRole = null; | |
this.user = null; | |
}; | |
return this; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment