BigSpaces

BigSpaces

Failing to create new user: Missing JWT signing secret

Hello there!

I am trying to create a user. Creation fails from both the admin dashboard, as well as the /register route

This is the error message in the console:

** (Ash.Error.Unknown) Unknown Error

Context: resolving data on perform Memento.Accounts.User.register_with_password
* Context: resolving data on perform Memento.Accounts.User.register_with_password

** (RuntimeError) Missing JWT signing secret. Please see the documentation for `AshAuthentication.Jwt` for details
  (ash_authentication 3.11.15) lib/ash_authentication/jwt/config.ex:150: AshAuthentication.Jwt.Config.token_signer/2
  (ash_authentication 3.11.15) lib/ash_authentication/jwt.ex:111: AshAuthentication.Jwt.token_for_user/3
  (ash_authentication 3.11.15) lib/ash_authentication/generate_token_change.ex:37: AshAuthentication.GenerateTokenChange.generate_token/3
  (ash_authentication 3.11.15) lib/ash_authentication/generate_token_change.ex:19: anonymous fn/4 in AshAuthentication.GenerateTokenChange.change/3
  (ash 2.15.19) lib/ash/changeset/changeset.ex:2221: anonymous fn/2 in Ash.Changeset.run_after_actions/3

I have followed the authentication tutorial from the getting started guide.

This is my User resource:

defmodule Memento.Accounts.User do
  use Ash.Resource,
    data_layer: AshPostgres.DataLayer,
    extensions: [AshAuthentication]

  attributes do
    uuid_primary_key :id
    attribute :email, :ci_string, allow_nil?: false
    attribute :hashed_password, :string, allow_nil?: false, sensitive?: true
  end

  authentication do
    api Memento.Accounts

    strategies do
      password :password do
        identity_field :email
        sign_in_tokens_enabled? true
      end
    end

    tokens do
      enabled? true
      token_resource Memento.Accounts.Token

      signing_secret fn _, _ ->
        Application.fetch_env(:my_app, :token_signing_secret)
      end
    end
  end

  postgres do
    table "users"
    repo Memento.Repo
  end

  identities do
    identity :unique_email, [:email]
  end


end

I appreciate any guidance you can provide to solve this one.

BigSpaces

First Post!

zachdaniel

zachdaniel

Creator of Ash

You should drop in an IO.inspect on the result of Application.fetch_env there. It is likely returning :error, and its probably returning that because your otp app isn’t called :my_app.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
New
Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement