git.fiddlerwoaroof.com
Browse code

Pass the clock by value to totp_generator

Ed Langley authored on 08/06/2017 00:14:16
Showing 2 changed files
... ...
@@ -61,7 +61,7 @@ unsigned long bytesToInt (const std::string &bytes)
61 61
 class token_generator_impl : public token_generator_ifc
62 62
 {
63 63
 private:
64
-    const sys_time &clock;
64
+    const sys_time clock;
65 65
     unsigned int code_digits;
66 66
     const std::string key;
67 67
 
... ...
@@ -99,7 +99,7 @@ private:
99 99
     }
100 100
 
101 101
 public:
102
-    token_generator_impl (const sys_time &clock,
102
+    token_generator_impl (const sys_time clock,
103 103
                           const std::string &key,
104 104
                           const int code_digits) :
105 105
         clock (clock), code_digits (code_digits),
... ...
@@ -122,10 +122,9 @@ public:
122 122
 // Generator goes here....
123 123
 
124 124
 totp_generator::totp_generator (
125
-    const sys_time &clock,
125
+    const sys_time clock,
126 126
     const std::string &key_c,
127 127
     const int code_digits) :
128 128
     delegate_ (std::make_shared<token_generator_impl> (clock, key_c,
129 129
                code_digits))
130 130
 {}
131
-
... ...
@@ -49,10 +49,9 @@ public:
49 49
         delegate_ (delegate_)
50 50
     {}
51 51
 
52
-    totp_generator (const sys_time &clock,
52
+    totp_generator (const sys_time clock,
53 53
                     const std::string &key_c,
54 54
                     const int code_digits);
55 55
 };
56 56
 
57 57
 #endif
58
-