use of com.fujieid.jap.social.SocialStrategy in project OneBlog by zhangyd-c.
the class OAuthController method renderAuth.
@RequestMapping("/social/{source}")
public ModelAndView renderAuth(@PathVariable("source") String source, HttpServletResponse response, HttpServletRequest request) {
SocialConfig socialConfig = sysSocialConfigService.getByPlatform(source);
if (null == socialConfig) {
throw new ZhydException(source + " 平台的配置尚未完成,暂时不支持登录!");
}
SocialStrategy socialStrategy = new SocialStrategy(japUserService, new JapConfig());
JapResponse japResponse = socialStrategy.authenticate(JapUtil.blogSocialConfig2JapSocialConfig(socialConfig, source), request, response);
if (!japResponse.isSuccess()) {
throw new ZhydException(japResponse.getMessage());
}
if (japResponse.isRedirectUrl()) {
return ResultUtil.redirect((String) japResponse.getData());
} else {
JapUser japUser = (JapUser) japResponse.getData();
User user = (User) japUser.getAdditional();
SessionUtil.setUser(user);
return ResultUtil.redirect("/");
}
}
Aggregations