Giter Club home page Giter Club logo

Comments (4)

hassox avatar hassox commented on May 19, 2024

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

from guardian.

ramstein74 avatar ramstein74 commented on May 19, 2024

coding this
image

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}

from guardian.

hassox avatar hassox commented on May 19, 2024

@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)

from guardian.

ramstein74 avatar ramstein74 commented on May 19, 2024

Solved
thank you

2016-01-11 18:30 GMT+00:00 Daniel Neighman [email protected]:

@ramstein74 https://github.com/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)

โ€”
Reply to this email directly or view it on GitHub
#82 (comment).

from guardian.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.