[Vuejs]-Authentication and Authorization in Elixir without Phoenix

0👍

Everything depends of what kind of auth you want to have and how you communicate with the Elixir backend. Assuming that you have Elixir running on somekind of webserver all you need to have is an interface between backend and front eg.

# function that checks whether user is authenticated
def authenticate(user, password) do
  password_hash = give_me_password_hash_for_user(user) 
  # how you want to retrieve that - maybe Ecto? Ecto is not a part of Phoenix
  if Comeonin.Bcrypt.checkpw(password, password_hash) do # using here Comeonin
    happy_path()
  else
    unauthorized_path()
  end
end

And of course you need to pass the information that the user is logged in – keep it in session or send the token (jwt or Phoenix – whatever) to each API call.

Leave a comment