나는 가까운 내가 결승선 냄새를 맡을 수 sooo를 오전 -
(이것은 내가 할 수있는 AngularJS와 SPA있어 내 응용 프로그램이 시작되면, 나는 사용자의 로그인 정보를 수확을 spInfoContext에서 쉽게 알 수 있습니다.) 그리고 userId에 대해 itiUsers이라는 목록을 검색하여 사용자가 돌아 오는 사용자인지 확인합니다. 레코드가 없으면 즉시 itiUsers에 새 레코드를 만든 다음 새 사용자가 SharePoint에서 가져올 수없는 정보를 입력 할 수있는 양식을 제공합니다. 레코드가 제대로 작성되었습니다. 약속이 돌아 왔을 때, $ scope.current_user 객체를 채우려고 노력하고 있습니다. 반환하는 사용자 인 경우와 같을 것입니다. 즉, 내 기본 설정 양식 만 있으면됩니다.
그러나 레코드를 만든 후 $ scope를 로그 아웃하면 current_user가 비어 있습니다.
가 여기 내 컨트롤러 기능이다 (나는 간결 값을 감소 나는 대담에 문제 라인 시도) :
$.when(SharePointJSOMService.getCurrentUser())
.done(function(jsonObject){
if(jsonObject.d.results.length < 1 || jsonObject.d.results.newUser){
// new user
$.when(SharePointJSOMService.getLoggedInUser())
.done(function(jsonObject){
$scope.loggedInUser = jsonObject.d;
$scope.isNewUser = true;
$.when(SharePointJSOMService.createNewUser($scope))
.done(function(jsonObject){
**$scope.current_user.DisplayName = $scope.loggedInUser.Title;
console.log($scope);**
})
.fail(function(err){
$scope.prefPane = true;
console.info(JSON.stringify(err));
});
})
.fail(function(err){
$scope.prefPane = true;
console.info(JSON.stringify(err));
});
$scope.prefPane = true; // force preference pane
$scope.taskClose = true;
$scope.$apply();
} else {
// existing user
$scope.isNewUser = false;
$scope.prefPane = false; // hide preference pane
$scope.current_user = jsonObject.d.results[0];
switch($scope.current_user.Role){
case 'USR':
$scope.projectClose = 'true';
break;
case 'PMG':
$scope.projectClose = 'false';
break;
default:
$scope.projectClose = 'true';
break;
} // end switch
$scope.$apply();
} // end if
})
.fail(function(err){
$scope.prefPane = true;
console.info(JSON.stringify(err));
});
첫 번째 블록에서는'$ scope.loggedInUser'를 설정하고 두 번째 (기존 사용자) 블록에서는'$ scope.currentUser'를 설정합니다. 그 맞습니까? –
예. loggedInUser는 SharePoint에 대한 사용자 정보를 포함합니다. current_user에는 itiUsers 테이블의 사용자에 대해 유지 관리하는 정보가 들어 있습니다. 모든 사용에는 loggedInUser 정보가 있지만 기존 사용자 만 current_user 정보를 갖습니다. 그러나 환경 설정 창에서 편집하지 않은 정보는 current_user에 지정해야 Prefs 양식이 작동합니다. 바로이 부분이 "$ scope.current_user.DisplayName = $ scope.loggedInUser.Title;" 선. 할당하지 말고 밀어 넣을까요? – jgravois