• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wger-project / flutter / 30854254088

03 Aug 2026 09:21PM UTC coverage: 40.895% (-15.0%) from 55.93%
30854254088

Pull #1260

github

web-flow
Merge d93794de5 into e3affdd4f
Pull Request #1260: WIP: health sync

9980 of 24404 relevant lines covered (40.89%)

1.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/features/auth/widgets/refresh_token_field.dart
1
/*
2
 * This file is part of wger Workout Manager <https://github.com/wger-project>.
3
 * Copyright (c) 2026 wger Team
4
 *
5
 * wger Workout Manager is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18

19
import 'package:flutter/material.dart';
20
import 'package:flutter/services.dart';
21
import 'package:wger/l10n/generated/app_localizations.dart';
22

23
/// Three dot-separated base64url segments: the standard JWT shape, which
24
/// covers the refresh tokens issued by `allauth.headless`. Permissive on
25
/// length so future format changes do not lock users out.
26
final RegExp _jwtShape = RegExp(r'^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$');
×
27

28
class RefreshTokenField extends StatefulWidget {
29
  final TextEditingController controller;
30

31
  const RefreshTokenField({required this.controller, super.key});
×
32

33
  @override
×
34
  State<RefreshTokenField> createState() => _RefreshTokenFieldState();
×
35
}
36

37
class _RefreshTokenFieldState extends State<RefreshTokenField> {
38
  bool isObscure = true;
39

40
  @override
×
41
  Widget build(BuildContext context) {
42
    final i18n = AppLocalizations.of(context);
×
43

44
    return TextFormField(
×
45
      key: const ValueKey('inputRefreshToken'),
46
      decoration: InputDecoration(
×
47
        labelText: i18n.refreshToken,
×
48
        helperText: i18n.refreshTokenHelperText,
×
49
        errorMaxLines: 2,
50
        helperMaxLines: 3,
51
        prefixIcon: const Icon(Icons.password),
52
        suffixIcon: IconButton(
×
53
          icon: Icon(isObscure ? Icons.visibility_off : Icons.visibility),
×
54
          onPressed: () {
×
55
            setState(() {
×
56
              isObscure = !isObscure;
×
57
            });
58
          },
59
        ),
60
      ),
61
      obscureText: isObscure,
×
62
      controller: widget.controller,
×
63
      textInputAction: TextInputAction.next,
64
      keyboardType: TextInputType.text,
65
      validator: (value) {
×
66
        if (value == null || value.isEmpty) {
×
67
          return i18n.invalidRefreshToken;
×
68
        }
69
        if (!_jwtShape.hasMatch(value)) {
×
70
          return i18n.refreshTokenValidChars;
×
71
        }
72
        return null;
73
      },
74
      inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r'\s'))],
×
75
    );
76
  }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc