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

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
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
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
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

Other popular topics Top

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
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
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 43622 214
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement