Allow to modify host when deleting account or changing password over web

This commit is contained in:
Christian Dröge 2016-02-04 21:31:16 +01:00
parent 942072cf9d
commit 30388fa2bf
1 changed files with 14 additions and 12 deletions

View File

@ -113,8 +113,8 @@ process([<<"new">>],
end; end;
process([<<"delete">>], process([<<"delete">>],
#request{method = 'POST', q = Q, lang = Lang, #request{method = 'POST', q = Q, lang = Lang,
host = Host}) -> host = _HTTPHost}) ->
case form_del_post(Q, Host) of case form_del_post(Q) of
{atomic, ok} -> {atomic, ok} ->
Text = (?T(<<"Your Jabber account was successfully " Text = (?T(<<"Your Jabber account was successfully "
"deleted.">>)), "deleted.">>)),
@ -129,8 +129,8 @@ process([<<"delete">>],
%% should include the host where the POST was sent. %% should include the host where the POST was sent.
process([<<"change_password">>], process([<<"change_password">>],
#request{method = 'POST', q = Q, lang = Lang, #request{method = 'POST', q = Q, lang = Lang,
host = Host}) -> host = _HTTPHost}) ->
case form_changepass_post(Q, Host) of case form_changepass_post(Q) of
{atomic, ok} -> {atomic, ok} ->
Text = (?T(<<"The password of your Jabber account " Text = (?T(<<"The password of your Jabber account "
"was successfully changed.">>)), "was successfully changed.">>)),
@ -361,7 +361,8 @@ form_changepass_get(Host, Lang) ->
?INPUTS(<<"text">>, <<"username">>, <<"">>, ?INPUTS(<<"text">>, <<"username">>, <<"">>,
<<"20">>)]), <<"20">>)]),
?XE(<<"li">>, ?XE(<<"li">>,
[?CT(<<"Server:">>), ?C(<<" ">>), ?C(Host)]), [?CT(<<"Server:">>), ?C(<<" ">>),
?INPUTS(<<"text">>, <<"host">>, Host, <<"20">>)]),
?XE(<<"li">>, ?XE(<<"li">>,
[?CT(<<"Old Password:">>), ?C(<<" ">>), [?CT(<<"Old Password:">>), ?C(<<" ">>),
?INPUTS(<<"password">>, <<"passwordold">>, <<"">>, ?INPUTS(<<"password">>, <<"passwordold">>, <<"">>,
@ -386,9 +387,9 @@ form_changepass_get(Host, Lang) ->
%%% Formulary change password POST %%% Formulary change password POST
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
form_changepass_post(Q, Host) -> form_changepass_post(Q) ->
case catch get_changepass_parameters(Q) of case catch get_changepass_parameters(Q) of
[Username, PasswordOld, Password, Password] -> [Username, Host, PasswordOld, Password, Password] ->
try_change_password(Username, Host, PasswordOld, try_change_password(Username, Host, PasswordOld,
Password); Password);
[_Username, _PasswordOld, _Password, _Password2] -> [_Username, _PasswordOld, _Password, _Password2] ->
@ -405,7 +406,7 @@ get_changepass_parameters(Q) ->
{value, {_Key, Value}} = lists:keysearch(Key, 1, Q), {value, {_Key, Value}} = lists:keysearch(Key, 1, Q),
Value Value
end, end,
[<<"username">>, <<"passwordold">>, <<"password">>, [<<"username">>, <<"host">>, <<"passwordold">>, <<"password">>,
<<"password2">>]). <<"password2">>]).
try_change_password(Username, Host, PasswordOld, try_change_password(Username, Host, PasswordOld,
@ -470,7 +471,8 @@ form_del_get(Host, Lang) ->
?INPUTS(<<"text">>, <<"username">>, <<"">>, ?INPUTS(<<"text">>, <<"username">>, <<"">>,
<<"20">>)]), <<"20">>)]),
?XE(<<"li">>, ?XE(<<"li">>,
[?CT(<<"Server:">>), ?C(<<" ">>), ?C(Host)]), [?CT(<<"Server:">>), ?C(<<" ">>),
?INPUTS(<<"text">>, <<"host">>, Host, <<"20">>)]),
?XE(<<"li">>, ?XE(<<"li">>,
[?CT(<<"Password:">>), ?C(<<" ">>), [?CT(<<"Password:">>), ?C(<<" ">>),
?INPUTS(<<"password">>, <<"password">>, <<"">>, ?INPUTS(<<"password">>, <<"password">>, <<"">>,
@ -513,9 +515,9 @@ register_account2(Username, Host, Password) ->
%%% Formulary delete POST %%% Formulary delete POST
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
form_del_post(Q, Host) -> form_del_post(Q) ->
case catch get_unregister_parameters(Q) of case catch get_unregister_parameters(Q) of
[Username, Password] -> [Username, Host, Password] ->
try_unregister_account(Username, Host, Password); try_unregister_account(Username, Host, Password);
_ -> {error, wrong_parameters} _ -> {error, wrong_parameters}
end. end.
@ -529,7 +531,7 @@ get_unregister_parameters(Q) ->
{value, {_Key, Value}} = lists:keysearch(Key, 1, Q), {value, {_Key, Value}} = lists:keysearch(Key, 1, Q),
Value Value
end, end,
[<<"username">>, <<"password">>]). [<<"username">>, <<"host">>, <<"password">>]).
try_unregister_account(Username, Host, Password) -> try_unregister_account(Username, Host, Password) ->
try unregister_account(Username, Host, Password) of try unregister_account(Username, Host, Password) of