@@ -49,10 +49,6 @@ defmodule AlgoraWeb.Onboarding.DevLive do
49
49
50
50
@ impl true
51
51
def mount ( _params , _session , socket ) do
52
- if connected? ( socket ) do
53
- Phoenix.PubSub . subscribe ( Algora.PubSub , "auth:#{ socket . id } " )
54
- end
55
-
56
52
context = % {
57
53
country: socket . assigns . current_country ,
58
54
tech_stack: [ ] ,
@@ -127,37 +123,37 @@ defmodule AlgoraWeb.Onboarding.DevLive do
127
123
{ :noreply , socket }
128
124
end
129
125
130
- @ impl true
131
- def handle_info ( { :authenticated , user } , socket ) do
132
- tech_stack = get_field ( socket . assigns . info_form . source , :tech_stack ) || [ ]
133
- intentions = get_field ( socket . assigns . info_form . source , :intentions ) || [ ]
134
-
135
- case user
136
- |> change (
137
- tech_stack: tech_stack ,
138
- seeking_bounties: "bounties" in intentions ,
139
- seeking_contracts: "contracts" in intentions ,
140
- seeking_jobs: "jobs" in intentions
141
- )
142
- |> Repo . update ( ) do
143
- { :ok , user } ->
144
- { :noreply , redirect ( socket , to: AlgoraWeb.UserAuth . generate_login_path ( user . email ) ) }
145
-
146
- { :error , changeset } ->
147
- Logger . error ( "Failed to update user #{ user . id } on onboarding: #{ inspect ( changeset ) } " )
148
- { :noreply , put_flash ( socket , :error , "Something went wrong. Please try again." ) }
149
- end
150
- end
151
-
152
126
@ impl true
153
127
def handle_event ( "restore_settings" , params , socket ) do
154
- { :noreply , LocalStore . restore ( socket , params ) }
128
+ socket = LocalStore . restore ( socket , params )
129
+
130
+ if user = socket . assigns [ :current_user ] do
131
+ tech_stack = get_field ( socket . assigns . info_form . source , :tech_stack ) || [ ]
132
+ intentions = get_field ( socket . assigns . info_form . source , :intentions ) || [ ]
133
+
134
+ case user
135
+ |> change (
136
+ tech_stack: tech_stack ,
137
+ seeking_bounties: "bounties" in intentions ,
138
+ seeking_contracts: "contracts" in intentions ,
139
+ seeking_jobs: "jobs" in intentions
140
+ )
141
+ |> Repo . update ( ) do
142
+ { :ok , user } ->
143
+ { :noreply , redirect ( socket , to: AlgoraWeb.UserAuth . generate_login_path ( user . email ) ) }
144
+
145
+ { :error , changeset } ->
146
+ Logger . error ( "Failed to update user #{ user . id } on onboarding: #{ inspect ( changeset ) } " )
147
+ { :noreply , put_flash ( socket , :error , "Something went wrong. Please try again." ) }
148
+ end
149
+ else
150
+ { :noreply , socket }
151
+ end
155
152
end
156
153
157
154
@ impl true
158
155
def handle_event ( "sign_in_with_github" , _params , socket ) do
159
- popup_url = Github . authorize_url ( % { socket_id: socket . id } )
160
- { :noreply , push_event ( socket , "open_popup" , % { url: popup_url } ) }
156
+ { :noreply , redirect ( socket , external: Github . authorize_url ( % { return_to: ~p" /onboarding/dev?checkpoint=1" } ) ) }
161
157
end
162
158
163
159
@ impl true
0 commit comments