-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no token on view ? #82
Comments
Hey. What do you have in your view? Its pretty good practice to pass the token in, but you can look it up from the conn object in views. I'm assuming that you normally comment out the current_token and inspect calls in your screen grab |
gives me this in my view %Plug.Conn{adapter: {Plug.Adapters.Cowboy.Conn, :...}, assigns: %{guardian_default_resource: nil, layout: {G1.LayoutView, "app.html"}, token: nil}, before_send: [#Function<1.117304339/1 in Plug.CSRFProtection.call/2>, #Function<2.92260701/1 in Phoenix.Controller.fetch_flash/2>, #Function<1.37606151/1 in Plug.Session.before_send/2>, #Function<1.21054194/1 in Plug.Logger.call/2>, #Function<0.53071751/1 in Phoenix.LiveReloader.before_send_inject_reloader/1>], body_params: %{}, cookies: %{"fileManager" => "760d8929-4618-d40c78709a76"}, halted: false, host: "127.0.0.1", method: "GET", owner: #PID<0.554.0>, params: %{}, path_info: [], peer: {{127, 0, 0, 1}, 26429}, port: 4000, private: %{G1.Router => {[], %{}}, :phoenix_action => :index, :phoenix_controller => G1.PageController, :phoenix_endpoint => G1.Endpoint, :phoenix_flash => %{}, :phoenix_format => "html", :phoenix_layout => {G1.LayoutView, :app}, :phoenix_pipelines => [:browser, :browser_session], :phoenix_route => #Function<1.108914464/1 in G1.Router.match_route/4>, :phoenix_router => G1.Router, :phoenix_template => "index.html", :phoenix_view => G1.PageView, :plug_session => %{}, :plug_session_fetch => :done}, query_params: %{}, query_string: "", remote_ip: {127, 0, 0, 1}, req_cookies: %{"fileManager" => "760d8929-4618-d40c78709a76"}, req_headers: [{"host", "127.0.0.1:4000"}, {"connection", "keep-alive"}, {"cache-control", "max-age=0"}, {"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8"}, {"upgrade-insecure-requests", "1"}, {"user-agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"}, {"accept-encoding", "gzip, deflate, sdch"}, {"accept-language", "pt-PT,pt;q=0.8,en-US;q=0.6,en;q=0.4"}, {"cookie", "fileManager=760d8929-4618-d40c78709a76"}], request_path: "/", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-request-id", "c5misd7pr05q6f22npbprl0tch84a8l0"}, {"x-frame-options", "SAMEORIGIN"}, {"x-xss-protection", "1; mode=block"}, {"x-content-type-options", "nosniff"}], scheme: :http, script_name: [], secret_key_base: "Qm9nsRw7p+//i2LLhojCxJU8uE1DVblY1KDl+DQnIURX2yvT2FgLfonK/fb2cmg3", state: :unset, status: nil} |
@ramstein74 the conn struct is immutable. You need to save off the new one after you sign in. conn = Guardian.Plug.sign_in(conn, user, :csrf)
render conn, "index.html", token: Guardian.Plug.current_token(conn) |
Solved 2016-01-11 18:30 GMT+00:00 Daniel Neighman notifications@github.com:
|
Hi, i´m sure its my error but i need more info to use guardian
here is my index page.
in the console i see the token being inspected
however in my index view
i have <%= inspect @conn %> and the token is not there.
if i change the return of index above to
render conn, "index.html" , token: Guardian.Plug.current_token(conn)
i see the token but is set to nill
Can you help a litle more ?
regards
António
The text was updated successfully, but these errors were encountered: