checkForm method
Validates a form submission by checking the hidden form key and timestamp.
name
- The name attribute for the hidden input field. Defaults to 'formChecker'.
Returns a bool indicating whether the form submission is valid.
Implementation
bool checkForm([String? name]) {
name = name ?? 'formChecker';
final dataField = data(name, def: 'unknown');
if (dataField != 'unknown') {
Map dataSession = getSession(name, def: 'unknown2') as Map;
if (dataField == dataSession['key']) {
int duration = DateTime.now().millisecondsSinceEpoch -
(dataSession['time'] as int);
if (duration / 1000 < 600) {
return true;
}
}
}
return false;
}