@@ -19,9 +19,16 @@ namespace sdk {
19
19
} // namespace
20
20
21
21
//
22
- // Common auth handling
22
+ // Auth handling interface
23
23
//
24
- auth_handler::auth_handler (session& session, const std::string& action, std::shared_ptr<signer> signer)
24
+ auth_handler::auth_handler () {}
25
+
26
+ auth_handler::~auth_handler () {}
27
+
28
+ //
29
+ // Common auth handling implementation
30
+ //
31
+ auth_handler_impl::auth_handler_impl (session& session, const std::string& action, std::shared_ptr<signer> signer)
25
32
: m_session(session)
26
33
, m_action(action)
27
34
, m_attempts_remaining(TWO_FACTOR_ATTEMPTS)
@@ -33,7 +40,7 @@ namespace sdk {
33
40
}
34
41
}
35
42
36
- auth_handler::auth_handler (session& session, const std::string& action)
43
+ auth_handler_impl::auth_handler_impl (session& session, const std::string& action)
37
44
: m_session(session)
38
45
, m_action(action)
39
46
, m_attempts_remaining(TWO_FACTOR_ATTEMPTS)
@@ -45,9 +52,9 @@ namespace sdk {
45
52
}
46
53
}
47
54
48
- auth_handler ::~auth_handler () {}
55
+ auth_handler_impl ::~auth_handler_impl () {}
49
56
50
- void auth_handler ::init (const std::string& action, std::shared_ptr<signer> signer, bool is_pre_login)
57
+ void auth_handler_impl ::init (const std::string& action, std::shared_ptr<signer> signer, bool is_pre_login)
51
58
{
52
59
m_signer = signer;
53
60
set_action (action);
@@ -58,7 +65,7 @@ namespace sdk {
58
65
m_state = m_methods.empty () ? state_type::make_call : state_type::request_code;
59
66
}
60
67
61
- void auth_handler ::set_action (const std::string& action)
68
+ void auth_handler_impl ::set_action (const std::string& action)
62
69
{
63
70
m_action = action;
64
71
m_is_hw_action = m_signer && m_signer->is_hw_device ()
@@ -68,26 +75,26 @@ namespace sdk {
68
75
|| action == " get_unspent_outputs" || action == " get_expired_deposits" );
69
76
}
70
77
71
- void auth_handler ::set_error (const std::string& error_message)
78
+ void auth_handler_impl ::set_error (const std::string& error_message)
72
79
{
73
80
GDK_LOG_SEV (log_level::debug) << m_action << " call exception: " << error_message;
74
81
m_state = state_type::error;
75
82
m_error = error_message;
76
83
}
77
84
78
- void auth_handler ::set_data ()
85
+ void auth_handler_impl ::set_data ()
79
86
{
80
87
m_twofactor_data
81
88
= { { " action" , m_action }, { " device" , m_is_hw_action ? m_signer->get_hw_device () : nlohmann::json () } };
82
89
}
83
90
84
- void auth_handler ::request_code (const std::string& method)
91
+ void auth_handler_impl ::request_code (const std::string& method)
85
92
{
86
93
request_code_impl (method);
87
94
m_attempts_remaining = TWO_FACTOR_ATTEMPTS;
88
95
}
89
96
90
- void auth_handler ::request_code_impl (const std::string& method)
97
+ void auth_handler_impl ::request_code_impl (const std::string& method)
91
98
{
92
99
GDK_RUNTIME_ASSERT (m_state == state_type::request_code);
93
100
@@ -100,14 +107,14 @@ namespace sdk {
100
107
m_state = state_type::resolve_code;
101
108
}
102
109
103
- void auth_handler ::resolve_code (const std::string& code)
110
+ void auth_handler_impl ::resolve_code (const std::string& code)
104
111
{
105
112
GDK_RUNTIME_ASSERT (m_state == state_type::resolve_code);
106
113
m_code = code;
107
114
m_state = state_type::make_call;
108
115
}
109
116
110
- void auth_handler ::operator ()()
117
+ void auth_handler_impl ::operator ()()
111
118
{
112
119
GDK_RUNTIME_ASSERT (m_state == state_type::make_call);
113
120
try {
@@ -149,7 +156,7 @@ namespace sdk {
149
156
}
150
157
}
151
158
152
- nlohmann::json auth_handler ::get_status () const
159
+ nlohmann::json auth_handler_impl ::get_status () const
153
160
{
154
161
GDK_RUNTIME_ASSERT (m_state == state_type::error || m_error.empty ());
155
162
0 commit comments