Comments (4)
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.
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.
@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.
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)
- Compilation error in file guardian.ex: type options/0 undefined HOT 1
- Is guardian relying on JWT's fixed side ? HOT 2
- Provide a way to retrieve verifying secret at runtime using connection information
- Help with EnsureNotAuthenticated HOT 1
- Successfully validates a JWT token with a timestamp in the past
- use Bitwise is deprecated in elixir 1.14-dev
- Warning causing compile error with Elixir 1.14.0 HOT 1
- Unable to set secret_key in runtime.exs HOT 12
- changelog is missing in the doc HOT 1
- all_permissions? function returns true even if permission set given is not within the list of permissions provided and compiled
- I would like to be able to set permissions from a DB table rather than hard coded in a permissions set. HOT 8
- guardian.encode_and_sign 1st argument: not an atom HOT 1
- Opaque errors when token verification fails HOT 3
- Using an environment variable as a secret key in elixir 1.14 HOT 2
- Breaking Change on 2.3.1 - Can't encode Bitwise Permissions HOT 6
- Generating a JWT with kty=oct can fail because of incorrect Base64 encoding
- after_encode_and_sign result not used HOT 2
- Move to Elixir 1.14 and otp 25 HOT 3
- system_time vs os_time and time drift HOT 1
- refresh_from_cookie only accepts "default" as key HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guardian.