feat: profile and subs
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user