     #client |> Exredis.stop
      
      
-    access_token = get_session(conn, :access_token) 
-    IO.puts "access_token"
-    if !access_token and !!access_url do 
-      IO.puts "access_token is empty"
-			case HTTPoison.get(access_url) do
-				{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
-          result = Poison.Parser.parse!(body)
-          IO.inspect result
-          conn = put_session(conn, :access_token, result["access_token"])
-          conn = put_session(conn, :openid, result["openid"])
-				{:ok, %HTTPoison.Response{status_code: 404}} ->
-					IO.puts "Not found :("
-				{:error, %HTTPoison.Error{reason: reason}} ->
-					IO.inspect reason
-			end    
-       
-    end 
-    access_token = get_session(conn, :access_token) 
-    openid = get_session(conn, :openid)
-    userinfo_url = "#{userinfo_base}?openid=#{openid}&access_token=#{access_token}"
-    IO.puts "access_token: #{access_token}"
-    IO.puts "openid: #{openid}"
-    if !is_nil(openid) do 
-      user =  Repo.get_by(User, openid: openid)
-    end
-      
-    # IO.puts "user: #{Length(user)}"
-    if !is_nil(openid) and !is_nil(access_token) do 
-    case HTTPoison.get(userinfo_url) do
-      {:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
-        result = Poison.Parser.parse!(body)
-        IO.inspect result
-        changeset = User.changeset(%User{}, %{"openid"=> result["openid"], "nickname"=> result["nickname"], 
-            "province"=> result["province"],
-             "country"=> result["country"],
-             "headimgurl"=> result["headimgurl"]})
-      
-        if !user do 
-          IO.puts "save"
-          Repo.insert(changeset)
-        else 
-          IO.puts "update"
-          # Repo.update(user,changeset) 
-        end
-      {:ok, %HTTPoison.Response{status_code: 404}} ->
-        IO.puts "Not found :("
-      {:error, %HTTPoison.Error{reason: reason}} ->
-        IO.inspect reason
-    end    
-
-    end
- 
     post = Repo.get!(Post, id) |> Repo.preload(:photos) |> Repo.preload :user
     render(conn, "show.html", post: post, layout: {Flour.LayoutView, "app.html"})
   end

    |> put_flash(:info, "Post deleted successfully.")
    |> redirect(to: post_path(conn, :index))
  end
end

  use Flour.Web, :controller
  require IEx
  require Exredis
  plug :auth
  plug :put_layout, "post.html"
  alias Flour.Post
  alias Flour.Photo
