Phoenix Internal Server Error when performing authorisation with guardian

Hey everyone, l av been learning phoenix for sometime now and currently i have dived in to authentication/authorization specifically with guardian.

In MyApp which performs user registration perfectly well a user has to sign in with email and password fields and i have a session controller for that. The weird experience i have is it works well when the user gives wrong sign in credentials by denying access and flashing an error Invalid email address or password but when putting the right credentials for signing in instead of a redirect the App crushes bring an Internal Server Error Message

I honestly have no idea

Without any code, it might be hard to answer.

Maybe You can start by showing the full error message :slight_smile:

okay maybe i share the code
my sessioncontoller.ex

defmodule MyApp.SessionController do
	use MyApp.Web, :controller

	alias MyApp.User

	import Comeonin.Bcrypt, only: [checkpw: 2, dummy_checkpw: 0]

	def new(conn, _params) do
		render conn, "new.html"
	end


  	def create(conn, %{"session" => %{"email" => email, "password" => password}}) do
	    case verify_credentials(email, password) do
	      {:ok, user} ->
	        conn
	        |> put_flash(:info, "Successfully signed in")
	        |> Guardian.Plug.sign_in(user)
	        |> redirect(to: profile_path(conn, :index))
	      {:error, _reason} ->
	        conn
	        |> put_flash(:error, "Invalid email address or password")
	        |> render("new.html")
	    end
  	end

  	def delete(conn, _params) do
	    conn
	    |> Guardian.Plug.sign_out()
	    |> put_flash(:info, "Successfully signed out")
	    |> redirect(to: "/")
 	 end

 	defp verify_credentials(email, password) when is_binary(email) and is_binary(password) do
   		with {:ok, user} <- find_by_email(email),
     	 do: verify_password(password, user)
  	end

  	defp find_by_email(email) when is_binary(email) do
	    case Repo.get_by(User, email: email) do
	      nil ->
	        dummy_checkpw()
	        {:error, "User with email '#{email}' not found"}
	      user ->
	        {:ok, user}
	    end
	end

	defp verify_password(password, %User{} = user) when is_binary(password) do
	    if checkpw(password, user.password_hash) do
	      {:ok, user}
	    else
	      {:error, :invalid_password}
	    end
  	end

end

my pipeline in the router

pipeline :browser_session do
    plug Guardian.Plug.VerifySession
    plug Guardian.Plug.LoadResource
    plug MyApp.GetUser
 end

and my plug

defmodule MyApp.GetUser do
	import Plug.Conn

	alias MyApp.Repo
	alias MyApp.User


	def init(opts) do
		opts
	end


	def call(conn, _opts) do
		current_user = Guardian.Plug.current_resource(conn)  
		assign(conn, :current_user, current_user)
	end
end

Actually the error is am directed to a page stating INTERNAL SERVER ERROR

This is everything that is shown on the page?

Is there a stack trace on the page or in your logs? Do your logs show anything at all?

[error] Loading of /home/mullah/myApp/_build/dev/lib/base64url/ebin/base64url.beam failed: :badfile

[error] #PID<0.449.0> running MyApp.Endpoint terminated
Server: 0.0.0.0:4000 (http)
Request: POST /sessions
** (exit) an exception was raised:
    ** (CaseClauseError) no case clause matching: {:error, :beam_lib, {:not_a_beam_file, ""}}
        (elixir) lib/code.ex:658: Code.do_get_docs/2
        (plug) lib/plug/debugger.ex:288: Plug.Debugger.get_doc/4
        (plug) lib/plug/debugger.ex:232: Plug.Debugger.each_frame/4
        (elixir) lib/enum.ex:1372: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
        (plug) lib/plug/debugger.ex:224: Plug.Debugger.frames/2
        (plug) lib/plug/debugger.ex:159: Plug.Debugger.render/6
        (plug) lib/plug/debugger.ex:129: Plug.Debugger.__catch__/5
        (myApp) lib/myApp/endpoint.ex:1: myApp.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /home/mullah/myApp/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Problem is solved. Got some help from elixir-lang Slack Channel.
Think is my dependancies were corrupted so suggestion was to run mix deps.clean --all and mix deps.get and restart the server