@@ -164,15 +164,11 @@ impl Adapter for EthereumAdapter {
164
164
Ok ( true )
165
165
}
166
166
167
- fn session_from_token ( & mut self , token : & str ) -> AdapterResult < Session > {
167
+ /// Creates a `Session` from a provided Token by calling the Contract.
168
+ /// Does **not** cache the (`Token`, `Session`) pair.
169
+ fn session_from_token ( & self , token : & str ) -> AdapterResult < Session > {
168
170
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 ( ) ) ;
171
+ return Err ( AdapterError :: Failed ( "invalid token id" . to_string ( ) ) ) ;
176
172
}
177
173
178
174
let parts: Vec < & str > = token. split ( '.' ) . collect ( ) ;
@@ -204,7 +200,7 @@ impl Adapter for EthereumAdapter {
204
200
let contract = get_contract ( & self . config , contract_address, & IDENTITY_ABI )
205
201
. map_err ( |_| map_error ( "failed to init identity contract" ) ) ?;
206
202
207
- let priviledge_level : U256 = contract
203
+ let privilege_level : U256 = contract
208
204
. query (
209
205
"privileges" ,
210
206
verified. from . to_string ( ) ,
@@ -215,7 +211,7 @@ impl Adapter for EthereumAdapter {
215
211
. wait ( )
216
212
. map_err ( |_| map_error ( "failed query priviledge level on contract" ) ) ?;
217
213
218
- if priviledge_level == * PRIVILEGE_LEVEL_NONE {
214
+ if privilege_level == * PRIVILEGE_LEVEL_NONE {
219
215
return Err ( AdapterError :: Authorization (
220
216
"insufficient privilege" . to_string ( ) ,
221
217
) ) ;
@@ -231,7 +227,6 @@ impl Adapter for EthereumAdapter {
231
227
} ,
232
228
} ;
233
229
234
- self . session_tokens . insert ( token_id, sess. clone ( ) ) ;
235
230
Ok ( sess)
236
231
}
237
232
0 commit comments