File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,10 @@ impl Adapter for EthereumAdapter {
185
185
}
186
186
187
187
fn session_from_token ( & self , token : & str ) -> AdapterResult < Session > {
188
+ if token. len ( ) < 16 {
189
+ return Err ( AdapterError :: Failed ( "invaild token id" . to_string ( ) ) ) ;
190
+ }
191
+
188
192
let token_id = token. to_owned ( ) [ token. len ( ) - 16 ..] . to_string ( ) ;
189
193
190
194
let mut session_tokens = self . session_tokens . borrow_mut ( ) ;
@@ -209,10 +213,8 @@ impl Adapter for EthereumAdapter {
209
213
}
210
214
} ;
211
215
212
- let verified = match ewt_verify ( header_encoded, payload_encoded, token_encoded) {
213
- Ok ( v) => v,
214
- Err ( e) => return Err ( AdapterError :: EwtVerifyFailed ( e. to_string ( ) ) ) ,
215
- } ;
216
+ let verified = ewt_verify ( header_encoded, payload_encoded, token_encoded)
217
+ . map_err ( |e| map_error ( & e. to_string ( ) ) ) ?;
216
218
217
219
if self . whoami ( ) ? != verified. payload . id {
218
220
return Err ( AdapterError :: Configuration (
You can’t perform that action at this time.
0 commit comments