verify method
Verify JSON Web Token
Implementation
Map<String, dynamic>? verify(
String token,
String secret, [
void Function(dynamic error, Map<String, dynamic>? data)? done,
]) {
try {
final jwt = JWT.verify(token, SecretKey(secret));
done?.call(null, jwt.payload as Map<String, dynamic>);
return jwt.payload;
} on JWTExpiredError {
if (done != null) {
done.call('JWTExpiredError', null);
} else {
throw JWTExpiredError();
}
} on JWTError catch (e) {
if (done != null) {
done.call(e.message, null);
} else {
throw JWTError(e.message);
}
} on Exception catch (e) {
if (done != null) {
done.call('Verify token failed', null);
} else {
throw Exception(e);
}
}
}