@@ -52,19 +52,19 @@ defmodule Codebattle.Auth.User.FirebaseUser do
5252 end
5353
5454 defp create_in_firebase ( % { email: email , password: password } ) do
55- case HTTPoison . post (
55+ case Req . post (
5656 "#{ firebase_url ( ) } :signUp?key=#{ api_key ( ) } " ,
57- Jason . encode! ( % { email: email , password: password } )
57+ json: % { email: email , password: password }
5858 ) do
59- { :ok , % HTTPoison .Response{ status_code : 200 , body: body } } ->
59+ { :ok , % Req .Response{ status : 200 , body: body } } ->
6060 firebase_uid =
6161 body
6262 |> Jason . decode! ( )
6363 |> Map . get ( "localId" )
6464
6565 { :ok , firebase_uid }
6666
67- { :ok , % HTTPoison .Response{ status_code : 400 , body: body } } ->
67+ { :ok , % Req .Response{ status : 400 , body: body } } ->
6868 error_message =
6969 body
7070 |> Jason . decode! ( )
@@ -73,28 +73,28 @@ defmodule Codebattle.Auth.User.FirebaseUser do
7373
7474 { :error , % { base: error_message } }
7575
76- { :ok , % HTTPoison .Response{ body: body } } ->
76+ { :ok , % Req .Response{ body: body } } ->
7777 { :error , % { base: "Something went wrong, pls, try again later. #{ inspect ( body ) } " } }
7878
79- { :error , % HTTPoison.Error { reason: reason } } ->
79+ { :error , reason } ->
8080 { :error , % { base: "Something went wrong, pls, try again later. #{ inspect ( reason ) } " } }
8181 end
8282 end
8383
8484 defp find_in_firebase ( % { email: email , password: password } ) do
85- case HTTPoison . post (
85+ case Req . post (
8686 "#{ firebase_url ( ) } :signInWithPassword?key=#{ api_key ( ) } " ,
87- Jason . encode! ( % { email: email , password: password , returnSecureToken: true } )
87+ json: % { email: email , password: password , returnSecureToken: true }
8888 ) do
89- { :ok , % HTTPoison .Response{ status_code : 200 , body: body } } ->
89+ { :ok , % Req .Response{ status : 200 , body: body } } ->
9090 firebase_uid =
9191 body
9292 |> Jason . decode! ( )
9393 |> Map . get ( "localId" )
9494
9595 { :ok , firebase_uid }
9696
97- { :ok , % HTTPoison .Response{ status_code : 400 , body: body } } ->
97+ { :ok , % Req .Response{ status : 400 , body: body } } ->
9898 error_message =
9999 body
100100 |> Jason . decode! ( )
@@ -103,23 +103,23 @@ defmodule Codebattle.Auth.User.FirebaseUser do
103103
104104 { :error , % { base: error_message } }
105105
106- { :ok , % HTTPoison .Response{ body: body } } ->
106+ { :ok , % Req .Response{ body: body } } ->
107107 { :error , % { base: "Something went wrong, pls, try again later. #{ inspect ( body ) } " } }
108108
109- { :error , % HTTPoison.Error { reason: reason } } ->
109+ { :error , reason } ->
110110 { :error , % { base: "Something went wrong, pls, try again later. #{ inspect ( reason ) } " } }
111111 end
112112 end
113113
114114 defp reset_in_firebase ( % { email: email } ) do
115- case HTTPoison . post (
115+ case Req . post (
116116 "#{ firebase_url ( ) } :sendOobCode?key=#{ api_key ( ) } " ,
117- Jason . encode! ( % { email: email , requestType: "PASSWORD_RESET" } )
117+ json: % { email: email , requestType: "PASSWORD_RESET" }
118118 ) do
119- { :ok , % HTTPoison .Response{ status_code : 200 } } ->
119+ { :ok , % Req .Response{ status : 200 } } ->
120120 :ok
121121
122- { :ok , % HTTPoison .Response{ status_code : 400 , body: body } } ->
122+ { :ok , % Req .Response{ status : 400 , body: body } } ->
123123 error_message =
124124 body
125125 |> Jason . decode! ( )
@@ -128,11 +128,11 @@ defmodule Codebattle.Auth.User.FirebaseUser do
128128
129129 { :error , % { base: error_message } }
130130
131- { :ok , % HTTPoison .Response{ body: body } } ->
131+ { :ok , % Req .Response{ body: body } } ->
132132 Logger . error ( inspect ( body ) )
133133 { :error , % { base: "Something went wrong, pls, try again later. #{ inspect ( body ) } " } }
134134
135- { :error , % HTTPoison.Error { reason: reason } } ->
135+ { :error , reason } ->
136136 Logger . error ( inspect ( reason ) )
137137 { :error , % { base: "Something went wrong, pls, try again later. #{ inspect ( reason ) } " } }
138138 end
0 commit comments