2013-09-27 1 views
0

FubuMVC를 사용하는 웹 응용 프로그램의 경우 CurrentUserPropertyBinder (아래 참조)을 구현했습니다.CurrentUserPropertyBinder 문제는 항상 사용자를 기억할 수 없습니다.

public class CurrentUserPropertyBinder : IPropertyBinder 
    { 
     private readonly Database _database; 
     private readonly ISecurityContext _security; 
     public CurrentUserPropertyBinder(Database database, ISecurityContext security) 
     { 
      _database = database; 
      _security = security; 
     } 
     public bool Matches(PropertyInfo property) 
     { 
      return property.PropertyType == typeof(User) 
       && property.Name == "CurrentUser"; 
     } 
     public void Bind(PropertyInfo property, IBindingContext context) 
     { 
      var currentUser = //check database passing the username to get further user details using _security.CurrentIdentity.Name 
      property.SetValue(context.Object, currentUser, null); 
     } 
    } 

내 사이트에 로그인하면 정상적으로 작동합니다. 나는 시도하고 fineUploader을 사용하여 파일을 가져올 때 CurrentUserPropertyBinder는이 작업을 수행하는 데 필요한 모든 정보를 가지고

(즉 _security.CurrentIdentity.Name가 올바른 사용자 정보를 가지고) (http://fineuploader.com/)이있는이 열립니다 표준 파일 다이얼로그 _security.CurrentIdentity.Name은 비어 있습니다.

사용자가 누군지 기억하지 못하는 것 같습니다. 이유를 모르겠습니다. 다른 모든 경로에서 작동하지만 사용자를 기억하지 못할 파일을 가져옵니다.

도와주세요! 미리 감사드립니다

참고 : 우리는 나는이에 대한 조치를 추측하고있어

+1

FubuMVC.Authentication 또는 다른 것을 사용하여 사용자를 인증하고 있습니까? – ventaur

+0

우리는 사용자를 인증하기 위해 FubuMVC.Authentication을 사용하고 있습니다. –

답변

2

인증에서 제외 된 사용자를 인증 할 FubuMVC.Authentication를 사용하는; 아마도 AJAX 전용 엔드 포인트/액션 일 것입니다. 그 행동이 어떻게 보이는지 보지 않고도, 지난 3 개월 정도 FubuMVC.Authentication을 업데이트했다면, 이것에 대한 간단한 수정으로 벗어날 수 있다고 생각합니다.

이 작업에 대해 통과 인증을 사용하도록 설정해야합니다. 기본적으로 FubuMVC.Auth는 인증이 필요한 작업에 대해 IPrincipal을 연결합니다. 다른 작업에서 해당 정보에 액세스하려면 통과 필터를 사용해야합니다. 다음은이를 수행하는 빠른 방법입니다.

  1. 수신 동의 인증 스루 전달할 [PassThroughAuthentication] 속성이 작업을 위해 엔드/컨트롤러 클래스, 이러한 특정 동작 방법에있어서, 또는 입력 모델 장식.

    [PassThroughAuthentication] 
    public AjaxContinuation post_upload_file(UploadInputModel input) { ... } 
    

    또는

    [PassThroughAuthentication] 
    public class UploadInputModel { ... } 
    
  2. 는 부트 스트랩 중에 FubuRegistry의 통과에 대한 작업 호출과 일치하도록 AuthenticationSettings을 변경합니다./_fubu/엔드

    ... 
    AlterSettings<AuthenticationSettings>(x => { 
        // Persistent cookie lasts 3 days ("remember me"). 
        x.ExpireInMinutes = 4320; 
    
        // Many ways to filter here. 
        x.PassThroughChains.InputTypeIs<UploadInputModel>(); 
    }); 
    

점검 액션 호출과 체인인가 통과 또는 인증 필터가되도록.

+0

감사합니다 - 이것은 훌륭한 대답이지만 여전히 동일한 문제가 있습니다./_fubu/endpoint를 볼 때 여전히 필터를 통과하기 전에 ModelBinding을 수행합니다. 그래서 나는 여전히 같은 문제가 있습니다. 뭔가 잘못하고있는 것 같아? –

+0

빠른 참고 - @ventaur - 위의 내 의견 외에도 내 입력 모델에는 바인딩하려고하는 속성이 있습니다. –

+0

Oy. 그것은 약간의 Catch-22입니다. 라우팅/입력 바인딩 전에 통과 필터를 재정렬 할 수 있다고 확신하지 않습니다. 나는이 큰 총을 부를 것이고, 그래서 우리는 당신에게 최고의 대답을 줄 수 있습니다. – ventaur