@davoodmehraban89 / LifeMate / commits / a563805
Fork 0

LifeMate — Personal, Family & Learning Companion

feat: complete invitation acceptance login flow

davoodmehraban89 committed Oct 5, 2026 at 07:58 UTC a5638054da86f51843e3c1366f3b988e7ea3b9d9
1 file changed +28 -3
apps/lifemate/lib/main.dart
+28 -3
@@ -14,7 +14,11 @@ class LifeMateApp extends StatelessWidget {
14 const accent = Color(0xFF4D86E8);
15 final uri = Uri.base;
16 final token = uri.queryParameters['token'];
17 - Widget entry = SignInPage(api: api);
17 + Widget entry = SignInPage(
18 + api: api,
19 + invitationToken:
20 + token != null && uri.path.contains('accept-invitation') ? token : null,
21 + );
22 if (token != null && uri.path.contains('verify-email')) {
23 entry = VerifyEmailPage(api: api, token: token);
24 } else if (token != null && uri.path.contains('reset-password')) {
@@ -64,8 +68,13 @@ String errorText(Object error) {
68 }
69
70 class SignInPage extends StatefulWidget {
67 - const SignInPage({super.key, required this.api});
71 + const SignInPage({
72 + super.key,
73 + required this.api,
74 + this.invitationToken,
75 + });
76 final IdentityApi api;
77 + final String? invitationToken;
78 @override
79 State<SignInPage> createState() => _SignInPageState();
80 }
@@ -87,8 +96,13 @@ class _SignInPageState extends State<SignInPage> {
96 setState(() { busy = true; error = null; });
97 try {
98 await widget.api.login(email.text, password.text);
99 + if (widget.invitationToken != null) {
100 + await widget.api.acceptInvitation(widget.invitationToken!);
101 + }
102 if (!mounted) return;
91 - Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_) => HomeShell(api: widget.api)));
103 + Navigator.of(context).pushReplacement(
104 + MaterialPageRoute(builder: (_) => HomeShell(api: widget.api)),
105 + );
106 } catch (e) {
107 if (mounted) setState(() => error = errorText(e));
108 } finally {
@@ -111,6 +125,17 @@ class _SignInPageState extends State<SignInPage> {
125 const Text('LifeMate', textAlign: TextAlign.center, style: TextStyle(fontSize: 32, fontWeight: FontWeight.w700)),
126 const Text('همراه شخصی، تحصیلی و خانوادگی', textAlign: TextAlign.center),
127 const SizedBox(height: 32),
128 + if (widget.invitationToken != null) ...[
129 + const Card(
130 + child: Padding(
131 + padding: EdgeInsets.all(12),
132 + child: Text(
133 + 'برای قبول دعوت خانواده، با همان ایمیلی که دعوت شده وارد شو.',
134 + ),
135 + ),
136 + ),
137 + const SizedBox(height: 12),
138 + ],
139 TextField(controller: email, keyboardType: TextInputType.emailAddress, decoration: const InputDecoration(labelText: 'ایمیل')),
140 const SizedBox(height: 12),
141 TextField(controller: password, obscureText: true, decoration: const InputDecoration(labelText: 'رمز عبور')),