feat: profile and subs

This commit is contained in:
2026-06-17 11:32:18 +03:30
parent 943ba13872
commit e9f294fa19
19 changed files with 1762 additions and 34 deletions
+12 -2
View File
@@ -13,8 +13,9 @@ class AuthRepository {
await _api.dio.post('/auth/login-otp', data: {'mobile': mobile});
}
/// اعتبارسنجی کد و ذخیره‌ی توکن JWT.
Future<void> verifyOtp(String mobile, String code) async {
/// اعتبارسنجی کد، ذخیره‌ی توکن JWT و بازگرداندنِ اینکه کاربر نام دارد یا نه.
/// اگر نام نداشته باشد، فرانت کاربر را به صفحه‌ی انتخاب نام/آواتار می‌برد.
Future<bool> verifyOtp(String mobile, String code) async {
final res = await _api.dio.post(
'/auth/check-otp',
data: {'mobile': mobile, 'token': code},
@@ -24,6 +25,15 @@ class AuthRepository {
throw Exception('no token in response');
}
await _storage.write(token);
final user = res.data['user'];
final name = (user is Map) ? user['first_name'] : null;
return name is String && name.trim().isNotEmpty;
}
/// تنظیم نام نمایشی و آواتار.
Future<void> updateProfile(String firstName, String avatar) async {
await _api.dio.post('/profile',
data: {'first_name': firstName, 'avatar': avatar});
}
Future<bool> isLoggedIn() async {