/**
 * Create with IntelliJ IDEA
 * Project name : oss
 * Package name : org.oss.controller
 * Author : Wukunmeng
 * User : wkm
 * Date : 17-1-17
 * Time : 下午4:31
 * ---------------------------------
 */
package org.oss.controller;

import net.sf.json.JSONObject;
import org.apache.http.client.fluent.Form;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.fluent.Response;

import javax.servlet.http.Cookie;

/**
 * Create with IntelliJ IDEA
 * Project name : oss
 * Package name : org.oss.controller
 * Author : Wukunmeng
 * User : wkm
 * Date : 17-1-17
 * Time : 下午4:31
 * ---------------------------------
 * To change this template use File | Settings | File and Code Templates.
 */
public class HomeController extends BaseController {


    public void login(){
        String name = getPara("name");
        String password = getPara("password");
        logger.info("user:{};password:{}",name,password);
        Response response = null;
        try {
            Request request = Request.Post(userCenterUrl + "/user/login");
            request.bodyForm(Form.form().add("user_name",name).add("user_password",password).build());
            response = request.execute();
            JSONObject body = JSONObject.fromObject(response.returnContent().asString());
            logger.info("body:{}",body.toString(4));
            if(body.getBoolean("success")){
                JSONObject data = body.getJSONObject("data");
                Cookie cookie = new Cookie("user_cookie_key",data.getString("token"));
                cookie.setDomain("wkm.vmovier.cc");
                cookie.setMaxAge(60*5);
                setCookie(cookie);
                render("/html/success.html");
                return;
            }
        } catch (Exception e){
            logger.error("message:{}",e);
            render("/html/fail.html");
        } finally {
            if(response != null){
                response.discardContent();

            }
        }
        render("/html/fail.html");
    }

    public void check(){
        String name = getCookie("user_cookie_key");
        logger.info("user:{}",name);
        render("/html/success.html");
    }

}

@@ -931,16 +931,107 @@
 sword);%0A
+        String host = getRequest().getHeader(%22Host%22);%0A        logger.info(%22host:%7B%7D%22,host);%0A
         
@@ -1663,24 +1663,12 @@
 ain(
-%22wkm.vmovier.cc%22
+host
 );%0A 

add host