'use strict';
|
|
define(['app'], function (app) {
|
app.factory('AuthSession', ['$http', '$window', '$log', '$rootScope', 'User',
|
function ($http, $window, $log, $rootScope, User) {
|
return {
|
login: function (credentials) {
|
var loginJson = 'j_username=' + encodeURIComponent(credentials.account) +
|
'&j_password=' + encodeURIComponent(credentials.password) + '&rememberMe=' + credentials.rememberMe;
|
|
return $http.post("security/login", loginJson, {
|
headers: {
|
'Content-Type': 'application/x-www-form-urlencoded'
|
}
|
}).then(function (response) {
|
$log.debug("로그인 결과 : ", response);
|
return response.data;
|
});
|
},
|
logout: function () {
|
// logout from the server
|
$http.get('security/logout').success(function (response) {
|
$log.debug("로그아웃성공");
|
// 초기화
|
$rootScope.users = [];
|
$rootScope.user = undefined;
|
$rootScope.workspaces = [];
|
$rootScope.workIssueTypes = []
|
$rootScope.projects = [];
|
$rootScope.authorities = {};
|
$rootScope.currentDetailIssueId = null;
|
|
$rootScope.webSocket = {
|
socket : null,
|
client : null
|
};
|
|
// to get a new csrf token call the api
|
User.getUserSession({});
|
return response;
|
});
|
}
|
};
|
}]);
|
});
|