added guardian login with views for their assigned childs
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/// A sign-in link from the guardian login mail
|
||||
/// (`https://<connect-host>/app/guardian-login?rid=…<=…`).
|
||||
class GuardianLoginLink {
|
||||
static const path = '/app/guardian-login';
|
||||
|
||||
final String requestId;
|
||||
final String linkToken;
|
||||
|
||||
const GuardianLoginLink({required this.requestId, required this.linkToken});
|
||||
|
||||
/// Parses [uri] if it is a guardian login link for the server at [apiBase].
|
||||
/// Links of another server (e.g. live link while the app points at beta)
|
||||
/// are rejected: the request only exists on the server that sent the mail.
|
||||
static GuardianLoginLink? parse(Uri uri, {required Uri apiBase}) {
|
||||
if (uri.scheme != 'https' || uri.host != apiBase.host) return null;
|
||||
final basePath = apiBase.path.endsWith('/')
|
||||
? apiBase.path.substring(0, apiBase.path.length - 1)
|
||||
: apiBase.path;
|
||||
if (uri.path != '$basePath$path') return null;
|
||||
final requestId = uri.queryParameters['rid'];
|
||||
final linkToken = uri.queryParameters['lt'];
|
||||
if (requestId == null || requestId.isEmpty) return null;
|
||||
if (linkToken == null || linkToken.isEmpty) return null;
|
||||
return GuardianLoginLink(requestId: requestId, linkToken: linkToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user