Use secret_key_base as token_signing_secret
I have the following code in
lib/example/accounts/user.ex
:
Is there a way to use the secret_key_base
which is already set in the Phoenix Application config instead of System.fetch_env("TOKEN_SIGNING_SECRET")
?5 Replies
I think you'd just use
Application.fetch_env()
to get your endpoint's secret_key_base
, right?but why do you want to use secret key base? defining the token signing secret in config works fine.
Application.get_env(:my_app, MyAppWeb.Endpoint)[:secret_key_base]
I would use
fetch_env
, as you'd want it to crash if there was no token defined.
You I guess that syntax would fail as well, since you're using access pattern... Nvm. 😄Thank you!