renderAuth function
Adds the signed-in sessions of an auth.show payload to block.
Implementation
void renderAuth(
LiveBlock block,
Map<String, Object?> payload, {
String? session,
}) {
final Object? key = payload['key'];
if (key == null) {
block.note(
'No auth key is set. Pass authKey to nylo.configure(...) in your '
'AppProvider.',
);
return;
}
final Object? sessions = payload['sessions'];
final List<Map<String, Object?>> found = [
if (sessions is List)
for (final Object? entry in sessions)
if (entry is Map) _map(entry),
];
if (found.isEmpty) {
block.note(
session == null
? 'Nobody is signed in (auth key $key)'
: 'Nobody is signed in to the $session session',
);
return;
}
for (final Map<String, Object?> entry in found) {
block
..heading('${entry['session']}')
..json(entry['user']);
}
}