Major update to code structure
* Split files into independent files based on functionality.
* Switch to bower/gulp for build.
Change-Id: Ibc775dd9b7f6a0a49f63c22162b7582e781e2d9c
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/app/common/services/userModel.js b/app/common/services/userModel.js
new file mode 100644
index 0000000..e44ba8c
--- /dev/null
+++ b/app/common/services/userModel.js
@@ -0,0 +1,49 @@
+/**
+ * userModel
+ *
+ * @module app/common/services/userModel
+ * @exports userModel
+ * @name userModel
+
+ * @version 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.services')
+ .service('userModel', ['APIUtils',function(APIUtils){
+ return {
+ login : function(username, password, callback){
+ APIUtils.login(username, password, function(response, error){
+ if(response &&
+ response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS){
+ sessionStorage.setItem('LOGIN_ID', username);
+ callback(true);
+ }else{
+ callback(false, error);
+ }
+ });
+ },
+ isLoggedIn : function(){
+ if(sessionStorage.getItem('LOGIN_ID') === null){
+ return false;
+ }
+ return true;
+ },
+ logout : function(callback){
+ APIUtils.logout(function(response, error){
+ if(response &&
+ response.status == APIUtils.API_RESPONSE.SUCCESS_STATUS){
+ sessionStorage.removeItem('LOGIN_ID');
+ callback(true);
+ }else{
+ callback(false, error);
+ }
+ });
+ }
+ };
+ }]);
+
+})(window.angular);
\ No newline at end of file