Skip to content

Commit ea430c1

Browse files
committed
Add clan base64 support
1 parent 9d107ec commit ea430c1

File tree

4 files changed

+9
-41
lines changed

4 files changed

+9
-41
lines changed

services/app/apps/codebattle/lib/codebattle/auth/external.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,5 @@ defmodule Codebattle.Auth.External do
6161
|> Map.get(:body)
6262
|> Map.take(["default_avatar_id", "id", "is_avatar_empty"])
6363
|> Runner.AtomizedMap.atomize()
64-
|> dbg()
6564
end
6665
end

services/app/apps/codebattle/lib/codebattle_web/controllers/ext_api/executor_controller.ex

Lines changed: 0 additions & 37 deletions
This file was deleted.

services/app/apps/codebattle/lib/codebattle_web/controllers/ext_api/user_controller.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,13 @@ defmodule CodebattleWeb.ExtApi.UserController do
153153
cast_changeset_attribute(changeset, :name, current_name <> generate_random_postfix())
154154
end
155155

156-
defp cast_clan(attrs, %{"clan" => clan}), do: cast_attribute(attrs, :clan, clan)
156+
defp cast_clan(attrs, %{"clan" => clan}) do
157+
try do
158+
cast_attribute(attrs, :clan, Base.decode64!(clan))
159+
rescue
160+
_ -> cast_attribute(attrs, :clan, clan)
161+
end
162+
end
157163
defp cast_clan(attrs, _params), do: attrs
158164

159165
defp build_random_name do

services/app/apps/codebattle/test/codebattle_web/controllers/ext_api/user_controller_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ defmodule CodebattleWeb.ExtApi.UserControllerTest do
1515
test "creates user with clan and auth token", %{conn: conn} do
1616
conn
1717
|> put_req_header("x-auth-key", "x-key")
18-
|> post(Routes.ext_api_user_path(conn, :create, %{name: "lol", clan: "kek", UID: "asdf", category: "cat"}))
18+
|> post(Routes.ext_api_user_path(conn, :create, %{name: "lol", clan: "S2xhbg==", UID: "asdf", category: "cat"}))
1919
|> json_response(200)
2020

2121
user = Repo.get_by(User, name: "lol")
22-
clan = Repo.get_by(Clan, name: "kek")
22+
clan = Repo.get_by(Clan, name: "Klan")
2323
assert "cat" == user.category
2424
assert "asdf" == user.external_oauth_id
2525
assert 1 == clan.creator_id

0 commit comments

Comments
 (0)