不采用放入session域对象的方式
###
public class TokenFilter implements ActionFilter {
private static final Log log = Logs.get();
private ApiService apiService= Mvcs.ctx().getDefaultIoc().get(ApiService.class);
public View match(ActionContext context) {
String appId = Strings.sNull(context.getRequest().getParameter("appId"));
String token = Strings.sNull(context.getRequest().getParameter("token"));
// String username = Strings.sNull(context.getRequest().getParameter("username"));
// if (!apiService.verifyToken(appId, token)) {
// return new UTF8JsonView(JsonFormat.compact()).setData(Result.error(-1,"token invalid"));
// }
NutMap nutMap=(NutMap) apiService.verifyToken(appId,token);
//{ok=true, userId=4d291f1ba5d14746a9fb51eaf09fc5c5}
if (!(Boolean) nutMap.get("ok")){
return new UTF8JsonView(JsonFormat.compact()).setData(Result.error(-1,"token invalid"));
}
return "sharp kill wendal :( ";
}
}
###