checkUserEmailVerified method

  1. @override
FutureOr<PassedHttpEntity> checkUserEmailVerified(
  1. RequestHolder request,
  2. ResponseHolder response,
  3. Map<String, dynamic> pathArgs
)
override

Implementation

@override
FutureOr<PassedHttpEntity> checkUserEmailVerified(
  RequestHolder request,
  ResponseHolder response,
  Map<String, dynamic> pathArgs,
) {
  return _wrapper(request, response, pathArgs, () async {
    // this userId will be provided only if the user is allowed to sign in with the provided jwt from the checkJwtForUserId middleware
    String? userId = request.context[ContextFields.userId];
    if (userId == null) {
      throw AuthNotAllowedException();
    }

    var verified = await authService.checkUserVerified(userId);
    if (verified == null) {
      throw NoUserRegisteredException();
    }
    if (verified != true) {
      throw UserEmailNotVerified();
    }

    return request;
  });
}