JwtPayload.fromMap constructor
JwtPayload.fromMap(
- Map<String, dynamic> map
)
Implementation
factory JwtPayload.fromMap(Map<String, dynamic> map) {
var name = '';
var subject = '';
var email = '';
var tenantId = '';
var tid = '';
var issuer = '';
var audience = '';
var permissions = const <String>[];
var isAdministrator = false;
var nbf = DateTime.now();
var exp = DateTime.now();
var emailVerified = false;
var extra = <String, dynamic>{};
for (var entry in map.entries) {
switch (entry.key) {
case 'name':
name = entry.value;
break;
case 'sub':
subject = entry.value;
break;
case 'email':
email = entry.value;
break;
case 'tid':
tid = entry.value ?? '';
break;
case 'tenantId':
tenantId = entry.value ?? '';
break;
case 'iss':
issuer = entry.value;
break;
case 'aud':
audience = entry.value;
break;
case 'nbf':
nbf = _getDateTime(entry.value.toString());
break;
case 'exp':
exp = _getDateTime(entry.value.toString());
break;
case 'scp':
permissions = entry.value as List<String>;
break;
case 'adm':
isAdministrator = entry.value;
break;
case 'email_verified':
emailVerified =
(entry.value.toString()).toLowerCase().trim() == 'true';
break;
default:
extra[entry.key] = entry.value;
break;
}
}
var payload = JwtPayload(
name: name,
subject: subject,
email: email,
issuer: issuer,
audience: audience,
notBefore: nbf,
expires: exp,
extra: extra,
emailVerified: emailVerified,
tenantId: tenantId,
tid: tid,
permissions: permissions,
isAdministrator: isAdministrator);
return payload;
}