@@ -38,8 +38,6 @@ pub struct EthereumAdapter {
38
38
keystore_json : Value ,
39
39
keystore_pwd : Password ,
40
40
config : Config ,
41
- // Auth tokens that we have verified (tokenId => session)
42
- session_tokens : HashMap < String , Session > ,
43
41
// Auth tokens that we've generated to authenticate with someone (address => token)
44
42
authorization_tokens : HashMap < String , String > ,
45
43
wallet : Option < SafeAccount > ,
@@ -72,7 +70,6 @@ impl EthereumAdapter {
72
70
address,
73
71
keystore_json,
74
72
keystore_pwd : opts. keystore_pwd . into ( ) ,
75
- session_tokens : HashMap :: new ( ) ,
76
73
authorization_tokens : HashMap :: new ( ) ,
77
74
wallet : None ,
78
75
config : config. to_owned ( ) ,
@@ -164,15 +161,11 @@ impl Adapter for EthereumAdapter {
164
161
Ok ( true )
165
162
}
166
163
167
- fn session_from_token ( & mut self , token : & str ) -> AdapterResult < Session > {
164
+ /// Creates a `Session` from a provided Token by calling the Contract.
165
+ /// Does **not** cache the (`Token`, `Session`) pair.
166
+ fn session_from_token ( & self , token : & str ) -> AdapterResult < Session > {
168
167
if token. len ( ) < 16 {
169
- return Err ( AdapterError :: Failed ( "invaild token id" . to_string ( ) ) ) ;
170
- }
171
-
172
- let token_id = token[ token. len ( ) - 16 ..] . to_string ( ) ;
173
-
174
- if let Some ( token) = self . session_tokens . get ( & token_id) {
175
- return Ok ( token. to_owned ( ) ) ;
168
+ return Err ( AdapterError :: Failed ( "invalid token id" . to_string ( ) ) ) ;
176
169
}
177
170
178
171
let parts: Vec < & str > = token. split ( '.' ) . collect ( ) ;
@@ -204,7 +197,7 @@ impl Adapter for EthereumAdapter {
204
197
let contract = get_contract ( & self . config , contract_address, & IDENTITY_ABI )
205
198
. map_err ( |_| map_error ( "failed to init identity contract" ) ) ?;
206
199
207
- let priviledge_level : U256 = contract
200
+ let privilege_level : U256 = contract
208
201
. query (
209
202
"privileges" ,
210
203
verified. from . to_string ( ) ,
@@ -215,7 +208,7 @@ impl Adapter for EthereumAdapter {
215
208
. wait ( )
216
209
. map_err ( |_| map_error ( "failed query priviledge level on contract" ) ) ?;
217
210
218
- if priviledge_level == * PRIVILEGE_LEVEL_NONE {
211
+ if privilege_level == * PRIVILEGE_LEVEL_NONE {
219
212
return Err ( AdapterError :: Authorization (
220
213
"insufficient privilege" . to_string ( ) ,
221
214
) ) ;
@@ -231,7 +224,6 @@ impl Adapter for EthereumAdapter {
231
224
} ,
232
225
} ;
233
226
234
- self . session_tokens . insert ( token_id, sess. clone ( ) ) ;
235
227
Ok ( sess)
236
228
}
237
229
0 commit comments