Skip to content

Commit

Permalink
Fix login for Chinese accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
adriankumpf committed Jul 8, 2021
1 parent 4f7b1f2 commit 2e23df4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/tesla_api/auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,17 @@ defmodule TeslaApi.Auth do
params = Keyword.put(params, :login_hint, email)

case load_form(params, cookies) do
{:ok, {form, _captcha, cookies, base_url}} ->
{:ok, {form, captcha, cookies, base_url}} ->
form =
form
|> Map.replace!("identity", email)
|> Map.replace!("credential", password)

form =
case captcha_code do
nil -> form
code -> Map.replace!(form, "captcha", code)
if captcha == nil or captcha_code == nil do
form
else
Map.replace!(form, "captcha", captcha_code)
end

with {:ok, %Tesla.Env{} = env} <-
Expand Down

0 comments on commit 2e23df4

Please sign in to comment.