2016-10-15 6 views
1

간단한 StormPath/Express 앱이 있고 사용자 등록 후 country의 기본값을 "world"(customData)로 설정하고 싶습니다. 나중에 사용자는 프로필 페이지의 모든 국가로 변경할 수 있습니다.StormPath 등록 후 기본값 설정

을 어떻게 사용하면 가장 좋은 방법일까요? 감사.

app.use(stormpath.init(app, { 
    preRegistrationHandler: function (formData, req, res, next) { 
    console.log('Got registration request', formData); 
    next(); 
} 

})); 

답변

0

당신은 등록이 완료되면 코드를 실행하기 위해 postRegistrationHandler를 사용하려면 =) 예를 들어

:

app.use(stormpath.init(app, { 
    postRegistrationHandler: (account, req, res, next) => { 
    account.getCustomData((err, data) => { 
     if (err) return next(err); 
     data.country = 'World'; 
     data.save((err) => { 
     if (err) return next(err); 
     next(); 
     }); 
    }); 
    }); 
});