com.eshore.uas.fillter.TFAAction Maven / Gradle / Ivy
package com.eshore.uas.fillter;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.eshore.tools.Json2StringEncoder;
import com.eshore.uas.extensions.Glue;
import com.eshore.uas.server.api.User;
/**
* 双因子认证登录
* @author eric
*
*/
public class TFAAction extends LoginAction {
@Override
public boolean accept(HttpServletRequest req) {
String e =req.getParameter("e");
if("2fa-login".equals(e))return true;
return false;
}
@Override
public void action(HttpServletRequest req, HttpServletResponse resp) {
String code = req.getParameter("code");
String token = req.getParameter("token");
String type = req.getParameter("type");
if("refresh".equals(type)) {
Glue.getTfaAbility().reflash(token, req);
write(resp,this.fixJsonp(this.warnInfo(req), req, resp));
return ;
}
User user = Glue.getTfaAbility().tfalogin(token, code, req);
if(user == null) req.setAttribute("msg", "验证码错误!");
if("st".equalsIgnoreCase(type)) {
dost(req, resp, user);
}else {
doLogin(req, resp, user);
}
}
}