beyond-all-reason / teiserver

Middleware server for online gaming
https://www.beyondallreason.info/
MIT License
47 stars 47 forks source link

Trying to log in to website with a smurf-linked or suspended account fails with a cryptic error message #301

Closed StanczakDominik closed 1 month ago

StanczakDominik commented 2 months ago

We have a pasta like this on the Discord:

Getting an Internal Server Error on the game website is usually a result of one of one of the following issues:

  • You may be suspended. Ensure that isn't the case by searching for your nickname in in https://discord.com/channels/549281623154229250/774771372579880980.
  • You may be trying to log in as a smurf-linked alt account. Try clearing your cookies or switching your browser. Also ensure you're logging in with the email/password combo for your original/main account, or an account you've explicitly gotten an exception for. Double-check this with the moderation team. Alt accounts are not allowed, try $text altaccount to learn why.

Please provide the username and email you're trying to log in with if these do not resolve your issue.

We should really have at least a better error message there! Something like "Report to the moderation on Discord, link here, #open-ticket channel, to figure out this issue.". If you figure out why this happens, I can optimize the error message :)

Phoenix error log on trying to log in with such an account locally # FunctionClauseError at GET / Exception: ** (FunctionClauseError) no function clause matching in Phoenix.Controller.redirect/2 (phoenix 1.7.6) lib/phoenix/controller.ex:489: Phoenix.Controller.redirect(%Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{}, body_params: %{}, cookies: %{"_teiserver_key" => "", "guardian_default_token" => ""}, halted: false, host: "localhost", method: "GET", owner: #PID<0.8553.0>, params: %{}, path_info: [], path_params: %{}, port: 4000, private: %{:phoenix_live_view => {TeiserverWeb.General.HomeLive.Index, [action: :index, router: TeiserverWeb.Router], %{extra: %{on_mount: [%{function: &Teiserver.Account.AuthPlug.on_mount/4, id: {Teiserver.Account.AuthPlug, :ensure_authenticated}, stage: :mount}]}, name: :general_index, vsn: 1717045533445647338}}, TeiserverWeb.Router => [], :guardian_module => Teiserver.Account.Guardian, :guardian_error_handler => Teiserver.Account.ErrorHandler, :plug_session_fetch => :done, :plug_session => %{"_csrf_token" => "", "guardian_default_token" => "", "phoenix_flash" => %{"info" => "Welcome back!"}}, :before_send => [#Function<0.71811376/1 in Plug.CSRFProtection.call/2>, #Function<4.39524426/1 in Phoenix.Controller.fetch_flash/2>, #Function<0.76384852/1 in Plug.Session.before_send/2>, #Function<0.54455629/1 in Plug.Telemetry.call/2>, #Function<1.18762665/1 in Phoenix.LiveReloader.before_send_inject_reloader/3>], :phoenix_router => TeiserverWeb.Router, :phoenix_endpoint => TeiserverWeb.Endpoint, :phoenix_format => "html", :phoenix_root_layout => %{_: {TeiserverWeb.Layouts, :root}}, :phoenix_request_logger => {"request_logger", "request_logger"}, :guardian_default_token => "", :guardian_default_claims => %{"aud" => "teiserver", "exp" => 1719639040, "iat" => 1717047040, "iss" => "teiserver", "jti" => "5cb1b197-770a-49a6-837c-b83309efabd7", "nbf" => 1717047039, "sub" => "178832", "typ" => "access"}, :guardian_default_resource => %Teiserver.Account.User{__meta__: #Ecto.Schema.Metadata<:loaded, "account_users">, id: , name: "", email: "", password: "$argon2id$v=19$m=65536,t=8,p=2$tj6o8GuFB8lA/lFYpgg1RQ$i58xas6YwpFbnJUmLeGUjC1Uj/zqJhjYUnrwgBLbW8g", icon: " fa-solid fa-user", colour: "#666666", data: %{"bot" => false, "chobby_hash" => nil, "country" => "PL", "discord_dm_channel" => nil, "discord_dm_channel_id" => nil, "discord_id" => nil, "email_change_code" => nil, "hw_hash" => nil, "last_login" => 28553290, "last_login_mins" => 28553290, "last_login_timex" => "2024-04-15T16:09:41.912400Z", "lobby_client" => "LuaLobby Chobby", "lobby_hash" => "3739827741 4963bcca5474f0ca", "password_hash" => "$argon2id$v=19$m=65536,t=8,p=2$lgt8kYXIYWaRR7ID64AJgQ$VIhs/hKz9ruFK4nzqSLOVqJud/Twh5q0f7QqiyzTeY4", ...}, roles: ["Trusted", "Verified"], permissions: ["Trusted", "Verified"], restrictions: [], restricted_until: nil, shadowbanned: false, last_login: nil, last_login_timex: ~U[2024-04-15 16:09:41Z], last_played: nil, last_logout: ~U[2024-04-15 16:09:57Z], discord_id: nil, discord_dm_channel_id: nil, steam_id: nil, user_configs: #Ecto.Association.NotLoaded<association :user_configs is not loaded>, clan_id: nil, ...}}, query_params: %{}, query_string: "", remote_ip: {127, 0, 0, 1}, req_cookies: %{"_teiserver_key" => "SFMyNTY.g3QAAAADbQAAAAtfY3NyZl90b2tlbm0AAAAYVksybWY2UHl1eVBqNGswanZhdmFyUGJVbQAAABZndWFyZGlhbl9kZWZhdWx0X3Rva2VubQAAAVZleUpoYkdjaU9pSklVelV4TWlJc0luUjVjQ0k2SWtwWFZDSjkuZXlKaGRXUWlPaUowWldselpYSjJaWElpTENKbGVIQWlPakUzTVRrMk16a3dOREFzSW1saGRDSTZNVGN4TnpBME56QTBNQ3dpYVhOeklqb2lkR1ZwYzJWeWRtVnlJaXdpYW5ScElqb2lOV05pTVdJeE9UY3ROemN3WVMwME9XRTJMVGd6TjJNdFlqZ3pNekE1WldaaFltUTNJaXdpYm1KbUlqb3hOekUzTURRM01ETTVMQ0p6ZFdJaU9pSXhOemc0TXpJaUxDSjBlWEFpT2lKaFkyTmxjM01pZlEuSHpDbG5MUFo1eXB6VFA3azJMN2JDQVhRZDdNNW9mR3lrajBLRGU2dm96bUZrRmFXa3lzNENaLXVpVWpqMERDSW5FQlg3alNzdzdmb1hLdmlvcTJPTGdtAAAADXBob2VuaXhfZmxhc2h0AAAAAW0AAAAEaW5mb20AAAANV2VsY29tZSBiYWNrIQ.SHmp3a_IRQlLlIwcwdR0lOOFtqlp6lo6rv2i6HisEdQ", "guardian_default_token" => "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZWlzZXJ2ZXIiLCJleHAiOjE3MTk2MzkwNDAsImlhdCI6MTcxNzA0NzA0MCwiaXNzIjoidGVpc2VydmVyIiwianRpIjoiMmI3YThmM2EtODE0ZS00MmViLThkMzItNzllMDdiMTRiZWZjIiwibmJmIjoxNzE3MDQ3MDM5LCJzdWIiOiIxNzg4MzIiLCJ0eXAiOiJyZWZyZXNoIn0.dcaFdyC7kIch6UI69_Y37kNGXNS56AQQ6jzzVKY-UPTs3kBtuFUPHtJt9L6zzkQgH6sy5aSWd4yCy6ogVyrmsg"}, req_headers: [{"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"}, {"accept-encoding", "gzip, deflate, br, zstd"}, {"accept-language", "en-US,en;q=0.5"}, {"connection", "keep-alive"}, {"cookie", }, {"dnt", "1"}, {"host", "localhost:4000"}, {"priority", "u=1"}, {"referer", "http://localhost:4000/login"}, {"sec-fetch-dest", "document"}, {"sec-fetch-mode", "navigate"}, {"sec-fetch-site", "same-origin"}, {"sec-fetch-user", "?1"}, {"sec-gpc", "1"}, {"upgrade-insecure-requests", "1"}, {"user-agent", "Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"}], request_path: "/", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-request-id", "F9QtL7rDWPF75ssAAKCE"}, {"referrer-policy", "strict-origin-when-cross-origin"}, {"x-content-type-options", "nosniff"}, {"x-download-options", "noopen"}, {"x-frame-options", "SAMEORIGIN"}, {"x-permitted-cross-domain-policies", "none"}], scheme: :http, script_name: [], secret_key_base: :..., state: :unset, status: nil}, "/logout") (teiserver 0.1.0) TeiserverWeb.Router.live_browser/2 (teiserver 0.1.0) lib/teiserver_web/router.ex:1: TeiserverWeb.Router.__pipe_through0__/1 (phoenix 1.7.6) lib/phoenix/router.ex:421: Phoenix.Router.__call__/5 (teiserver 0.1.0) lib/teiserver_web/endpoint.ex:1: TeiserverWeb.Endpoint.plug_builder_call/2 (teiserver 0.1.0) lib/plug/debugger.ex:136: TeiserverWeb.Endpoint."call (overridable 3)"/2 (teiserver 0.1.0) lib/teiserver_web/endpoint.ex:1: TeiserverWeb.Endpoint.call/2 (phoenix 1.7.6) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4 (plug_cowboy 2.6.1) lib/plug/cowboy/handler.ex:11: Plug.Cowboy.Handler.init/2 (cowboy 2.10.0) /home/dominik/Projects/BAR/teiserver/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2 (cowboy 2.10.0) /home/dominik/Projects/BAR/teiserver/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3 (cowboy 2.10.0) /home/dominik/Projects/BAR/teiserver/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3 (stdlib 5.2.3) proc_lib.erl:241: :proc_lib.init_p_do_apply/3 Code: `lib/phoenix/controller.ex` 484 iex> redirect(conn, to: "/login") 485 486 iex> redirect(conn, external: "https://elixir-lang.org") 487 488 """ 489> def redirect(conn, opts) when is_list(opts) do 490 url = url(opts) 491 html = Plug.HTML.html_escape(url) 492 body = "<html><body>You are being <a href=\"#{html}\">redirected</a>.</body></html>" 493 494 conn Called with 2 arguments * `%Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{user_token: nil, current_user: nil, flash: %{"info" => "Welcome back!"}, site_menu_active: "", sub_menu_active: "", section_menu_active: ""}, body_params: %{}, cookies: %{}, halted: false, host: "localhost", method: "GET", owner: #PID<0.8553.0>, params: %{}, path_info: [], path_params: %{}, port: 4000, private: %{:phoenix_live_view => {TeiserverWeb.General.HomeLive.Index, [action: :index, router: TeiserverWeb.Router], %{extra: %{on_mount: [%{function: &Teiserver.Account.AuthPlug.on_mount/4, id: {Teiserver.Account.AuthPlug, :ensure_authenticated}, stage: :mount}]}, name: :general_index, vsn: }}, TeiserverWeb.Router => [], :guardian_module => Teiserver.Account.Guardian, :guardian_error_handler => Teiserver.Account.ErrorHandler, :plug_session_fetch => :done, :plug_session => %{"_csrf_token" => "", "guardian_default_token" => "", "phoenix_flash" => %{"info" => "Welcome back!"}}, :before_send => [#Function<0.71811376/1 in Plug.CSRFProtection.call/2>, #Function<4.39524426/1 in Phoenix.Controller.fetch_flash/2>, #Function<0.76384852/1 in Plug.Session.before_send/2>, #Function<0.54455629/1 in Plug.Telemetry.call/2>, #Function<1.18762665/1 in Phoenix.LiveReloader.before_send_inject_reloader/3>], :phoenix_router => TeiserverWeb.Router, :phoenix_endpoint => TeiserverWeb.Endpoint, :phoenix_format => "html", :phoenix_root_layout => %{_: {TeiserverWeb.Layouts, :root}}, :phoenix_request_logger => {"request_logger", "request_logger"}, :guardian_default_token => "", :guardian_default_claims => %{"aud" => "teiserver", "exp" => 1719639040, "iat" => 1717047040, "iss" => "teiserver", "jti" => "5cb1b197-770a-49a6-837c-b83309efabd7", "nbf" => 1717047039, "sub" => "178832", "typ" => "access"}, :guardian_default_resource => %Teiserver.Account.User{}, req_headers: [{"accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"}, {"accept-encoding", "gzip, deflate, br, zstd"}, {"accept-language", "en-US,en;q=0.5"}, {"connection", "keep-alive"}, {"cookie", }, {"dnt", "1"}, {"host", "localhost:4000"}, {"priority", "u=1"}, {"referer", "http://localhost:4000/login"}, {"sec-fetch-dest", "document"}, {"sec-fetch-mode", "navigate"}, {"sec-fetch-site", "same-origin"}, {"sec-fetch-user", "?1"}, {"sec-gpc", "1"}, {"upgrade-insecure-requests", "1"}, {"user-agent", "Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"}], request_path: "/", resp_body: nil, resp_cookies: %{}, resp_headers: [{"cache-control", "max-age=0, private, must-revalidate"}, {"x-request-id", "F9QtL7rDWPF75ssAAKCE"}, {"referrer-policy", "strict-origin-when-cross-origin"}, {"x-content-type-options", "nosniff"}, {"x-download-options", "noopen"}, {"x-frame-options", "SAMEORIGIN"}, {"x-permitted-cross-domain-policies", "none"}], scheme: :http, script_name: [], secret_key_base: :..., state: :unset, status: nil}` * `"/logout"` Attempted function clauses (showing 1 out of 1) def redirect(conn, opts) when is_list(opts) `nofile` No code available. `lib/teiserver_web/router.ex` 1> defmodule TeiserverWeb.Router do 2 use TeiserverWeb, :router 3 4 pipeline :logging_live_auth do 5 plug Bodyguard.Plug.Authorize, 6 policy: Teiserver.Logging.LiveLib, `lib/phoenix/router.ex` 416 start = System.monotonic_time() 417 measurements = %{system_time: System.system_time()} 418 metadata = %{metadata | conn: conn} 419 :telemetry.execute([:phoenix, :router_dispatch, :start], measurements, metadata) 420 421> case pipeline.(conn) do 422 %Plug.Conn{halted: true} = halted_conn -> 423 measurements = %{duration: System.monotonic_time() - start} 424 metadata = %{metadata | conn: halted_conn} 425 :telemetry.execute([:phoenix, :router_dispatch, :stop], measurements, metadata) 426 halted_conn `lib/teiserver_web/endpoint.ex` 1> defmodule TeiserverWeb.Endpoint do 2 use Phoenix.Endpoint, otp_app: :teiserver 3 4 @session_options [ 5 store: :cookie, 6 key: "_teiserver_key", `lib/plug/debugger.ex` No code available. `lib/teiserver_web/endpoint.ex` 1> defmodule TeiserverWeb.Endpoint do 2 use Phoenix.Endpoint, otp_app: :teiserver 3 4 @session_options [ 5 store: :cookie, 6 key: "_teiserver_key", `lib/phoenix/endpoint/sync_code_reload_plug.ex` 17 18 def call(conn, {endpoint, opts}), do: do_call(conn, endpoint, opts, true) 19 20 defp do_call(conn, endpoint, opts, retry?) do 21 try do 22> endpoint.call(conn, opts) 23 rescue 24 exception in [UndefinedFunctionError] -> 25 case exception do 26 %UndefinedFunctionError{module: ^endpoint} when retry? -> 27 # Sync with the code reloader and retry once `lib/plug/cowboy/handler.ex` 6 def init(req, {plug, opts}) do 7 conn = @connection.conn(req) 8 9 try do 10 conn 11> |> plug.call(opts) 12 |> maybe_send(plug) 13 |> case do 14 %Plug.Conn{adapter: {@connection, %{upgrade: {:websocket, websocket_args}} = req}} = conn -> 15 {handler, state, cowboy_opts} = websocket_args 16 {__MODULE__, copy_resp_headers(conn, req), {handler, state}, cowboy_opts} `/home/dominik/Projects/BAR/teiserver/deps/cowboy/src/cowboy_handler.erl` 32 -optional_callbacks([terminate/3]). 33 34 -spec execute(Req, Env) -> {ok, Req, Env} 35 when Req::cowboy_req:req(), Env::cowboy_middleware:env(). 36 execute(Req, Env=#{handler := Handler, handler_opts := HandlerOpts}) -> 37> try Handler:init(Req, HandlerOpts) of 38 {ok, Req2, State} -> 39 Result = terminate(normal, Req2, State, Handler), 40 {ok, Req2, Env#{result => Result}}; 41 {Mod, Req2, State} -> 42 Mod:upgrade(Req2, Env, Handler, State); `/home/dominik/Projects/BAR/teiserver/deps/cowboy/src/cowboy_stream_h.erl` 301 end. 302 303 execute(_, _, []) -> 304 ok; 305 execute(Req, Env, [Middleware|Tail]) -> 306> case Middleware:execute(Req, Env) of 307 {ok, Req2, Env2} -> 308 execute(Req2, Env2, Tail); 309 {suspend, Module, Function, Args} -> 310 proc_lib:hibernate(?MODULE, resume, [Env, Tail, Module, Function, Args]); 311 {stop, _Req2} -> `/home/dominik/Projects/BAR/teiserver/deps/cowboy/src/cowboy_stream_h.erl` 290 %% to simplify the debugging of errors. The proc_lib library 291 %% already adds the stacktrace to other types of exceptions. 292 -spec request_process(cowboy_req:req(), cowboy_middleware:env(), [module()]) -> ok. 293 request_process(Req, Env, Middlewares) -> 294 try 295> execute(Req, Env, Middlewares) 296 catch 297 exit:Reason={shutdown, _}:Stacktrace -> 298 erlang:raise(exit, Reason, Stacktrace); 299 exit:Reason:Stacktrace when Reason =/= normal, Reason =/= shutdown -> 300 erlang:raise(exit, {Reason, Stacktrace}, Stacktrace) `proc_lib.erl` No code available. ## Connection details ### Params %{} ### Request info * URI: http://localhost:4000/ * Query string: ### Headers * accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 * accept-encoding: gzip, deflate, br, zstd * accept-language: en-US,en;q=0.5 * connection: keep-alive * cookie: _teiserver_key= * dnt: 1 * host: localhost:4000 * priority: u=1 * referer: http://localhost:4000/login * sec-fetch-dest: document * sec-fetch-mode: navigate * sec-fetch-site: same-origin * sec-fetch-user: ?1 * sec-gpc: 1 * upgrade-insecure-requests: 1 * user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0 ### Session %{"_csrf_token" => "", "guardian_default_token" => "", "phoenix_flash" => %{"info" => "Welcome back!"}}
L-e-x-o-n commented 2 months ago

Already reported in #253

StanczakDominik commented 1 month ago

Closed by #302