Skip to content
Browse files

WHISTLE-824: only attempt to import the account def if it is missing

  • Loading branch information...
1 parent 3bdba93 commit d9265b862b23f0021be6e4573d0edf5805113cde @k-anderson k-anderson committed
Showing with 17 additions and 17 deletions.
  1. +17 −17 whistle_apps/apps/crossbar/src/modules/cb_shared_auth.erl
View
34 whistle_apps/apps/crossbar/src/modules/cb_shared_auth.erl
@@ -420,23 +420,23 @@ import_missing_account(AccountId, Account) ->
?LOG("remote account db ~s alread exists locally", [AccountId]),
%% make sure the account definition is in the account, if not
%% use the one we got from shared auth
- Event = <<"v1_resource.execute.post.accounts">>,
- Doc = case couch_mgr:open_doc(Db, AccountId) of
- {error, not_found} ->
- ?LOG("missing local account definition, creating from shared auth response"),
- wh_json:delete_key(<<"_rev">>, Account);
- {ok, JObj} ->
- ?LOG("account definition exists locally"),
- JObj
- end,
- Payload = [undefined, #cb_context{doc=Doc, db_name=Db}, AccountId],
- case crossbar_bindings:fold(Event, Payload) of
- [_, #cb_context{resp_status=success} | _] ->
- ?LOG("udpated account definition"),
- true;
- _ ->
- ?LOG("could not update account definition"),
- false
+ case couch_mgr:open_doc(Db, AccountId) of
+ {error, not_found} ->
+ ?LOG("missing local account definition, creating from shared auth response"),
+ Doc = wh_json:delete_key(<<"_rev">>, Account),
+ Event = <<"v1_resource.execute.post.accounts">>,
+ Payload = [undefined, #cb_context{doc=Doc, db_name=Db}, AccountId],
+ case crossbar_bindings:fold(Event, Payload) of
+ [_, #cb_context{resp_status=success} | _] ->
+ ?LOG("udpated account definition"),
+ true;
+ _ ->
+ ?LOG("could not update account definition"),
+ false
+ end;
+ {ok, _} ->
+ ?LOG("account definition exists locally"),
+ true
end;
false ->
?LOG("remote account db ~s does not exist locally, creating", [AccountId]),

0 comments on commit d9265b8

Please sign in to comment.
Something went wrong with that request. Please try again.