ZastrixArundell

ZastrixArundell

Can't start comeonin with Bcrypt

I am adding user Authentication to my webapp and for some reason I am having issues and really don’t know how to solve it (I don’t know if it’s an error on my side or a bug).

(Just as an heads up, I am using windows and I have nmake installed)

I try to add comeonin and Bcrypt like so:

     {:comeonin, "~> 5.0"},
     {:bcrypt_elixir, "~> 2.0"}

Then I do mix deps,get and mix deps.compile bcrypt_elixir, which works completely well and I don’t get any errors.

When I do mix phoenix.server I get the following warning (I am using hash_pwd_salt/1):

warning: function Comeonin.Bcrypt.hash_pwd_salt/1 is undefined or private. Did you mean one of:

      * hashpwsalt/1
      * hashpwsalt/2

If I try using hashpwsalt/1 I get:

** (exit) an exception was raised:
    ** (ArgumentError) Comeonin.Bcrypt.hashpwsalt has been removed.
Add {:bcrypt_elixir, "~> 2.0"} to the deps in your mix.exs file,
and use Bcrypt.hash_pwd_salt instead.

        lib/comeonin/base.ex:32: Comeonin.Bcrypt.error/2
        (ecto) lib/ecto/changeset.ex:1004: Ecto.Changeset.update_change/3
        (dealmailer) web/controllers/user_controller.ex:12: Dealmailer.UserController.create/2
        (dealmailer) web/controllers/user_controller.ex:1: Dealmailer.UserController.action/2
        (dealmailer) web/controllers/user_controller.ex:1: Dealmailer.UserController.phoenix_controller_pipeline/2
        (dealmailer) lib/dealmailer/endpoint.ex:1: Dealmailer.Endpoint.instrument/4
        (dealmailer) lib/phoenix/router.ex:261: Dealmailer.Router.dispatch/2
        (dealmailer) web/router.ex:1: Dealmailer.Router.do_call/2
        (dealmailer) lib/dealmailer/endpoint.ex:1: Dealmailer.Endpoint.phoenix_pipeline/1
        (dealmailer) lib/plug/debugger.ex:123: Dealmailer.Endpoint."call (overridable 3)"/2
        (dealmailer) lib/dealmailer/endpoint.ex:1: Dealmailer.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) c:/Users/Zastrix/Documents/Phoenix/dealmailer-phoenix/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Then I try to downgrade my versions:

     {:comeonin, "~> 4.0"},
     {:bcrypt_elixir, "~> 1.0"}

And I get the dependencies and compile, everything is okay. I don’t get warnings in console when I start the app but when I do actually run it… I get this again (I am using hashpwsalt/1 here)

** (exit) an exception was raised:
    ** (ArgumentError) Comeonin.Bcrypt.hashpwsalt has been removed.
Add {:bcrypt_elixir, "~> 2.0"} to the deps in your mix.exs file,
and use Bcrypt.hash_pwd_salt instead.

        lib/comeonin/base.ex:32: Comeonin.Bcrypt.error/2
        (ecto) lib/ecto/changeset.ex:1004: Ecto.Changeset.update_change/3
        (dealmailer) web/controllers/user_controller.ex:12: Dealmailer.UserController.create/2
        (dealmailer) web/controllers/user_controller.ex:1: Dealmailer.UserController.action/2
        (dealmailer) web/controllers/user_controller.ex:1: Dealmailer.UserController.phoenix_controller_pipeline/2
        (dealmailer) lib/dealmailer/endpoint.ex:1: Dealmailer.Endpoint.instrument/4
        (dealmailer) lib/phoenix/router.ex:261: Dealmailer.Router.dispatch/2
        (dealmailer) web/router.ex:1: Dealmailer.Router.do_call/2
        (dealmailer) lib/dealmailer/endpoint.ex:1: Dealmailer.Endpoint.phoenix_pipeline/1
        (dealmailer) lib/plug/debugger.ex:123: Dealmailer.Endpoint."call (overridable 3)"/2
        (dealmailer) lib/dealmailer/endpoint.ex:1: Dealmailer.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) c:/Users/Zastrix/Documents/Phoenix/dealmailer-phoenix/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Marked As Solved

wolfiton

wolfiton

Hi,

Can you update your bcrypt to use {bcrypt, "~> 2.0.3"},

Also have a look at the docs Bcrypt — bcrypt_elixir v3.3.2

Can you also share the file where you use bcrypt to register the users?

Also Liked

LostKobrakai

LostKobrakai

Yes and no. comeonin still holds the behaviour all the concrete packages implement. It’s a dependency of all of them. If you depend on the behaviour of comeonin and not just a single concrete implementation I feels it’s still good to list comeonin as explicit dependency. Because switching to another password hashing package does not change your dependency on the common interface.

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
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
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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 44265 214
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement