Skip to content

Commit

Permalink
Fail auth actions after 3 incorrect codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jgriffiths committed Nov 28, 2018
1 parent 044daa2 commit de17c76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
10 changes: 3 additions & 7 deletions src/ga_auth_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,20 @@ namespace sdk {
auto details = get_error_details(e);
if (is_twofactor_invalid_code_error(details.second)) {
// The caller entered the wrong code
// FIXME: Go back to resolve code if the methods time limit is up
// FIXME: If we are rate limited, move to error with a message
// FIXME: Error if the methods time limit is up or we are rate limited
if (m_method != "gauth" && --m_attempts_remaining == 0) {
// No more attempts left.
// Caller should request another code/choose another method
m_state = state_type::request_code;
// No more attempts left, caller should try the action again
set_error(res::id_invalid_twofactor_code);
} else {
// Caller should try entering the code again
m_state = state_type::resolve_code;
}
} else {
details = remap_ga_server_error(details);
set_error(details.second.empty() ? std::string(e.what()) : details.second);
m_state = state_type::error;
}
} catch (const std::exception& e) {
set_error(m_action + std::string(" exception:") + e.what());
m_state = state_type::error;
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/ga_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ namespace sdk {
const std::string id_choose_twofactor_authentication{
"id_choose_twofactor_authentication"
}; // Choose Two-Factor Authentication method
const std::string id_choose_word_number_d_from_the{
"id_choose_word_number_d_from_the"
}; // Choose word number %d from the options
const std::string id_clear{ "id_clear" }; // CLEAR
const std::string id_completed{ "id_completed" }; // Completed
const std::string id_configure_pin{ "id_configure_pin" }; // Configure PIN
Expand Down Expand Up @@ -103,7 +100,7 @@ namespace sdk {
const std::string id_date{ "id_date" }; // Date
const std::string id_day{ "id_day" }; // day
const std::string id_days{ "id_days" }; // days
const std::string id_days_remaining_s_s{ "id_days_remaining_s_s" }; // Days remaining %s %s
const std::string id_days_remaining_s{ "id_days_remaining_s" }; // Days remaining: %s
const std::string id_default_custom_fee_rate{ "id_default_custom_fee_rate" }; // Default custom fee rate
const std::string id_default_transaction_priority{
"id_default_transaction_priority"
Expand All @@ -119,6 +116,7 @@ namespace sdk {
"id_displays_the_progress_of_spv"
}; // Displays the progress of SPV synchronization
const std::string id_dispute_twofactor_reset{ "id_dispute_twofactor_reset" }; // Dispute Two-Factor reset
const std::string id_disputed{ "id_disputed" }; // Disputed
const std::string id_done{ "id_done" }; // Done
const std::string id_dont_store_your_mnemonic_in{
"id_dont_store_your_mnemonic_in"
Expand Down Expand Up @@ -237,6 +235,7 @@ namespace sdk {
const std::string id_invalid_replacement_fee_rate{
"id_invalid_replacement_fee_rate"
}; // Invalid replacement fee rate
const std::string id_invalid_twofactor_code{ "id_invalid_twofactor_code" }; // Invalid Two-Factor code
const std::string id_invalid_url{ "id_invalid_url" }; // Invalid URL
const std::string id_is_a_noncustodial{ "id_is_a_noncustodial" }; // is a non-custodial
const std::string id_last_ping_1d_ms{ "id_last_ping_1d_ms" }; // Last ping: %1$d ms
Expand Down Expand Up @@ -400,6 +399,7 @@ namespace sdk {
const std::string id_second{ "id_second" }; // second
const std::string id_seconds{ "id_seconds" }; // seconds
const std::string id_select_network{ "id_select_network" }; // Select network
const std::string id_select_word_number_d{ "id_select_word_number_d" }; // Select word number %d
const std::string id_send{ "id_send" }; // Send
const std::string id_send_all_funds{ "id_send_all_funds" }; // Send All Funds
const std::string id_send_all_requires_a_single{
Expand Down Expand Up @@ -580,9 +580,9 @@ namespace sdk {
const std::string id_your_s_sent_to_s_has_been{
"id_your_s_sent_to_s_has_been"
}; // Your %s sent to %s has been confirmed
const std::string id_your_sent_and_recieved{
"id_your_sent_and_recieved"
}; // Your sent and recieved transactions will be shown here.
const std::string id_your_sent_and_received{
"id_your_sent_and_received"
}; // Your sent and received transactions will be shown here.
const std::string id_your_transaction_threshold_is_s{
"id_your_transaction_threshold_is_s"
}; // Your transaction threshold is %s.
Expand Down
8 changes: 5 additions & 3 deletions src/ga_strings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ namespace sdk {
extern const std::string id_change;
extern const std::string id_choose;
extern const std::string id_choose_twofactor_authentication;
extern const std::string id_choose_word_number_d_from_the;
extern const std::string id_clear;
extern const std::string id_completed;
extern const std::string id_configure_pin;
Expand All @@ -73,7 +72,7 @@ namespace sdk {
extern const std::string id_date;
extern const std::string id_day;
extern const std::string id_days;
extern const std::string id_days_remaining_s_s;
extern const std::string id_days_remaining_s;
extern const std::string id_default_custom_fee_rate;
extern const std::string id_default_transaction_priority;
extern const std::string id_delete_pin;
Expand All @@ -82,6 +81,7 @@ namespace sdk {
extern const std::string id_deposit;
extern const std::string id_displays_the_progress_of_spv;
extern const std::string id_dispute_twofactor_reset;
extern const std::string id_disputed;
extern const std::string id_done;
extern const std::string id_dont_store_your_mnemonic_in;
extern const std::string id_dont_take_screenshots_of_your;
Expand Down Expand Up @@ -152,6 +152,7 @@ namespace sdk {
extern const std::string id_invalid_pin_you_dont_have_any;
extern const std::string id_invalid_pin_you_have_1d;
extern const std::string id_invalid_replacement_fee_rate;
extern const std::string id_invalid_twofactor_code;
extern const std::string id_invalid_url;
extern const std::string id_is_a_noncustodial;
extern const std::string id_last_ping_1d_ms;
Expand Down Expand Up @@ -263,6 +264,7 @@ namespace sdk {
extern const std::string id_second;
extern const std::string id_seconds;
extern const std::string id_select_network;
extern const std::string id_select_word_number_d;
extern const std::string id_send;
extern const std::string id_send_all_funds;
extern const std::string id_send_all_requires_a_single;
Expand Down Expand Up @@ -361,7 +363,7 @@ namespace sdk {
extern const std::string id_your_green_wallet_is_now_ready;
extern const std::string id_your_notifications_will_be;
extern const std::string id_your_s_sent_to_s_has_been;
extern const std::string id_your_sent_and_recieved;
extern const std::string id_your_sent_and_received;
extern const std::string id_your_transaction_threshold_is_s;
extern const std::string id_your_wallet_is_not_yet_fully;
extern const std::string id_your_watchonly_username_will_be;
Expand Down

0 comments on commit de17c76

Please sign in to comment.