All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.eshore.uas.fillter.TFAAction Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
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);
		}
	}
	
	

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy