auth with password added
This commit is contained in:
parent
b49beb06e8
commit
cd0c924cff
@ -1,7 +1,5 @@
|
||||
// api_config.dart
|
||||
// const String apiUrl = 'http://127.0.0.1:8090';
|
||||
// const String apiUrl = 'https://pbdev.venbait.in/';
|
||||
const String apiUrl = 'https://pb.venbait.in/';
|
||||
// const String apiUrl = 'https://pocket.fcsc.gov.ae';
|
||||
// const String auth = 'kannan@sightspectrum.com';
|
||||
// const String authpw = '1DgZ_we3k5UuCZiF9wziwECQzQo1YNRQ';
|
||||
// const String apiUrl = 'https://pb.venbait.in/';
|
||||
const String apiUrl = 'https://pocket.fcsc.gov.ae/';
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:uae_stat/config/theme/auth_provider.dart';
|
||||
import 'package:uae_stat/config/theme/service.dart';
|
||||
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
|
||||
import 'package:uae_stat/domain/entities/session_entity.dart';
|
||||
import 'package:uae_stat/infrastructure/services/pocketbase_service.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@ -55,17 +56,17 @@ class _SessionCheckScreenState extends ConsumerState<SessionCheckScreen> {
|
||||
// final String adminToken = adminAuth.token;
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
print('adminToken: $adminToken');
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
// print('adminToken: $adminToken');
|
||||
|
||||
// Fetch user details
|
||||
final userDetailsResponse = await pb.collection('users').getOne(
|
||||
userId!,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}',
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:uae_stat/infrastructure/services/pocketbase_service.dart';
|
||||
|
||||
class AuthState {
|
||||
final String email;
|
||||
|
||||
@ -56,32 +56,32 @@ class ThemeBaseService {
|
||||
|
||||
Future<dynamic> getUserTheme(String userId, WidgetRef ref) async {
|
||||
print('getUserTheme');
|
||||
final url = "${pb.baseUrl}/api/collections/users/records/$userId";
|
||||
final url = "${pb.baseUrl}api/collections/users/records/$userId";
|
||||
|
||||
// final adminAuth = await pb.admins.authWithPassword(
|
||||
// 'pb@venbainfotech.com',
|
||||
// 'pb@venbainfotech.com',
|
||||
// );
|
||||
|
||||
final auth = ref.watch(authProvider);
|
||||
// final auth = ref.watch(authProvider);
|
||||
|
||||
final adminAuth = await pb.admins.authWithPassword(
|
||||
auth.email,
|
||||
auth.password,
|
||||
);
|
||||
// final adminAuth = await pb.admins.authWithPassword(
|
||||
// auth.email,
|
||||
// auth.password,
|
||||
// );
|
||||
|
||||
// final adminAuth = await PocketBaseService.users.authWithPassword(
|
||||
// 'sangeethae9919@gmail.com',
|
||||
// 'Sang@123',
|
||||
// );
|
||||
|
||||
final String adminToken = adminAuth.token;
|
||||
print('adminToken: $adminToken');
|
||||
// final String adminToken = adminAuth.token;
|
||||
// print('adminToken: $adminToken');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $adminToken'
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}'
|
||||
},
|
||||
);
|
||||
|
||||
@ -104,7 +104,7 @@ class ThemeBaseService {
|
||||
String userId, String theme, WidgetRef ref) async {
|
||||
print('updateUserTheme');
|
||||
// Authenticate admin d
|
||||
final url = "${pb.baseUrl}/api/collections/users/records/$userId";
|
||||
final url = "${pb.baseUrl}api/collections/users/records/$userId";
|
||||
// final adminAuth = await pb.admins.authWithPassword(
|
||||
// 'pb@venbainfotech.com',
|
||||
// 'pb@venbainfotech.com',
|
||||
@ -112,18 +112,18 @@ class ThemeBaseService {
|
||||
|
||||
final auth = ref.watch(authProvider);
|
||||
|
||||
final adminAuth = await pb.admins.authWithPassword(
|
||||
auth.email,
|
||||
auth.password,
|
||||
);
|
||||
final String adminToken = adminAuth.token;
|
||||
print('adminToken: $adminToken');
|
||||
// final adminAuth = await pb.admins.authWithPassword(
|
||||
// auth.email,
|
||||
// auth.password,
|
||||
// );
|
||||
// final String adminToken = adminAuth.token;
|
||||
print('adminToken: ${PocketBaseService.authStore.token}');
|
||||
|
||||
final response = await http.patch(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}',
|
||||
},
|
||||
body: jsonEncode({
|
||||
'theme': theme, // light, dark, or system
|
||||
|
||||
@ -231,11 +231,9 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
isRegistering = true; // Disable the button
|
||||
});
|
||||
try {
|
||||
final adminAuth = await pb.admins
|
||||
.authWithPassword('kannan@sightspectrum.com', '1DgZ_we3k5UuCZiF9wziwECQzQo1YNRQ');
|
||||
|
||||
final adminToken = adminAuth.token;
|
||||
print('adminTokenREgistration- ${adminToken}');
|
||||
// final adminToken = adminAuth.token;
|
||||
// print('adminTokenREgistration- ${adminToken}');
|
||||
var mailID = _emailController.text;
|
||||
var email = mailID.toLowerCase();
|
||||
// Create user in PocketBase
|
||||
@ -247,7 +245,7 @@ class _RegisterScreenState extends ConsumerState<RegisterScreen> {
|
||||
'status': 'Pending',
|
||||
'role': 'user',
|
||||
}, headers: {
|
||||
'Authorization': adminToken
|
||||
// 'Authorization': adminToken
|
||||
});
|
||||
if (response.id != null) {
|
||||
userID = response.id;
|
||||
|
||||
@ -20,6 +20,7 @@ import 'package:uae_stat/config/toast_util.dart';
|
||||
import 'package:uae_stat/config/toggle_lang_service.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/uae_numbers_asset_path.dart';
|
||||
import 'package:uae_stat/infrastructure/services/pocketbase_service.dart';
|
||||
import 'package:uae_stat/presentation/Screens/charts/services/api_service.dart';
|
||||
import 'package:uae_stat/presentation/Screens/charts/widgets/chart_widget.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
@ -157,15 +158,15 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
// final adminToken = adminAuth.token;
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
|
||||
final result = await _pb.collection('bookmark').getList(
|
||||
filter: "user_id = '${userID}' && dataset = '${widget.dataSets}'",
|
||||
headers: {
|
||||
'Authorization': adminToken, // Pass the admin token
|
||||
'Authorization': PocketBaseService.authStore.token, // Pass the admin token
|
||||
},
|
||||
);
|
||||
|
||||
@ -190,11 +191,11 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
|
||||
final auth = ref.watch(authProvider);
|
||||
|
||||
final adminAuth = await pb.admins.authWithPassword(
|
||||
auth.email,
|
||||
auth.password,
|
||||
);
|
||||
final adminToken = adminAuth.token;
|
||||
// final adminAuth = await pb.admins.authWithPassword(
|
||||
// auth.email,
|
||||
// auth.password,
|
||||
// );
|
||||
// final adminToken = adminAuth.token;
|
||||
final response = await _pb.collection('bookmark').create(body: {
|
||||
'user_id': userID,
|
||||
'dataset': widget.dataSets,
|
||||
@ -203,7 +204,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
'title': widget.title,
|
||||
'keyParam': widget.keyParam,
|
||||
}, headers: {
|
||||
'Authorization': adminToken
|
||||
'Authorization': PocketBaseService.authStore.token
|
||||
});
|
||||
|
||||
setState(() {
|
||||
@ -250,12 +251,12 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
/// Remove bookmark from PocketBase
|
||||
Future<void> removeBookmark() async {
|
||||
try {
|
||||
final adminAuth = await _pb.admins
|
||||
.authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com');
|
||||
final adminToken = adminAuth.token;
|
||||
// final adminAuth = await _pb.admins
|
||||
// .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com');
|
||||
// final adminToken = adminAuth.token;
|
||||
if (bookmarkId != null) {
|
||||
await _pb.collection('bookmark').delete(bookmarkId!, headers: {
|
||||
'Authorization': adminToken,
|
||||
'Authorization': PocketBaseService.authStore.token,
|
||||
});
|
||||
|
||||
setState(() {
|
||||
|
||||
@ -13,7 +13,7 @@ class ChartData {
|
||||
}
|
||||
|
||||
class ApiService {
|
||||
static const String baseUrl = '$apiUrl/api/getDataSet';
|
||||
static const String baseUrl = '${apiUrl}api/getDataSet';
|
||||
|
||||
Future<Map<String, dynamic>> fetchChartData(String dataSets, locale, kpi,
|
||||
List<Map<String, dynamic>> filterData, themeMode) async {
|
||||
|
||||
@ -22,6 +22,7 @@ import 'package:uae_stat/config/theme/theme_provider.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart';
|
||||
import 'package:uae_stat/infrastructure/services/pocketbase_service.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
import 'package:uae_stat/presentation/components/my_toggle.dart';
|
||||
import 'package:uae_stat/l10n/app_localizations.dart';
|
||||
@ -178,15 +179,15 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
// final adminToken = adminAuth.token;
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
print('adminToken- ${adminToken}');
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
// print('adminToken- ${adminToken}');
|
||||
final userDetailsResponse = await _pb.collection('users').getOne(
|
||||
widget.userId,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}',
|
||||
},
|
||||
);
|
||||
print('userDetails: $userDetailsResponse');
|
||||
@ -375,7 +376,7 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
|
||||
// Create a multipart request
|
||||
final uri =
|
||||
Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID');
|
||||
Uri.parse('${_pb.baseUrl}api/collections/users/records/$userID');
|
||||
final request = http.MultipartRequest('PATCH', uri);
|
||||
|
||||
// Add other fields
|
||||
|
||||
@ -74,15 +74,15 @@ class LoginRoute extends HookConsumerWidget {
|
||||
// );
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
// Fetch user details
|
||||
final userDetailsResponse = await pb.collection('users').getOne(
|
||||
userId,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}',
|
||||
},
|
||||
);
|
||||
|
||||
@ -186,7 +186,7 @@ class LoginRoute extends HookConsumerWidget {
|
||||
|
||||
Future<void> updateDeviceToken(
|
||||
String userId, String token, WidgetRef ref) async {
|
||||
final url = "${pb.baseUrl}/api/collections/users/records/$userId";
|
||||
final url = "${pb.baseUrl}api/collections/users/records/$userId";
|
||||
|
||||
try {
|
||||
// Authenticate admin (Persist session globally instead)
|
||||
@ -203,16 +203,16 @@ class LoginRoute extends HookConsumerWidget {
|
||||
// );
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
|
||||
final response = await http.patch(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Add this
|
||||
'Authorization': pb.authStore.token, // Correct way to send auth token
|
||||
'Authorization': PocketBaseService.authStore.token, // Correct way to send auth token
|
||||
},
|
||||
body: jsonEncode({
|
||||
"device_token": token,
|
||||
@ -497,10 +497,10 @@ class LoginRoute extends HookConsumerWidget {
|
||||
// );
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
final userDetails = metaDetails['rawUser'];
|
||||
print('oauthDetails $userDetails');
|
||||
|
||||
@ -508,7 +508,7 @@ class LoginRoute extends HookConsumerWidget {
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Add this
|
||||
'Authorization': pb.authStore.token, // Correct way to send auth token
|
||||
'Authorization': PocketBaseService.authStore.token, // Correct way to send auth token
|
||||
},
|
||||
body: jsonEncode({
|
||||
"user_mail_verify": true,
|
||||
|
||||
@ -114,7 +114,7 @@ class _UaenumberWidgetState extends ConsumerState<uaenumberWidget> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -1017,7 +1017,7 @@ class EconomyStatsState extends ConsumerState<EconomyStatsWidget> {
|
||||
// }
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getHomePageData';
|
||||
const baseUrl = '${apiUrl}api/getHomePageData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -71,7 +71,7 @@ class _BookMarkState extends ConsumerState<BookMark> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
@ -128,7 +128,7 @@ class _BookMarkState extends ConsumerState<BookMark> {
|
||||
}
|
||||
|
||||
final response = await Dio().get(
|
||||
'$apiUrl/api/getUserBookmark',
|
||||
'${apiUrl}api/getUserBookmark',
|
||||
queryParameters: {
|
||||
'user_id': userID,
|
||||
'language': locale,
|
||||
@ -264,18 +264,18 @@ class _BookMarkState extends ConsumerState<BookMark> {
|
||||
//
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
print('adminTokenETRE1- ');
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
// print('adminTokenETRE1- ');
|
||||
|
||||
// final adminToken = adminAuth.token;
|
||||
|
||||
print('adminTokenETRE- $adminToken');
|
||||
// print('adminTokenETRE- $adminToken');
|
||||
|
||||
await _pb.collection('bookmark').delete(bookmarkId!, headers: {
|
||||
'Authorization': adminToken,
|
||||
'Authorization': PocketBaseService.authStore.token,
|
||||
});
|
||||
|
||||
// currentTheme = ref.read(themeProvider);
|
||||
|
||||
@ -51,7 +51,7 @@ class _ContactState extends ConsumerState<Contact> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(
|
||||
|
||||
@ -23,6 +23,7 @@ import 'package:uae_stat/config/theme/theme_provider.dart';
|
||||
import 'package:uae_stat/config/toggle_lang_service.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/misc_icon_asset_path.dart';
|
||||
import 'package:uae_stat/infrastructure/services/pocketbase_service.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/notification/notification.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart';
|
||||
@ -197,15 +198,15 @@ class _EditProfileState extends ConsumerState<EditProfile> {
|
||||
// final adminToken = adminAuth.token;
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
print('adminToken- $adminToken');
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
// print('adminToken- $adminToken');
|
||||
final userDetailsResponse = await _pb.collection('users').getOne(
|
||||
userId,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}',
|
||||
},
|
||||
);
|
||||
|
||||
@ -449,7 +450,7 @@ class _EditProfileState extends ConsumerState<EditProfile> {
|
||||
}
|
||||
|
||||
// Add headers (e.g., authorization)
|
||||
request.headers['Authorization'] = 'Bearer ${_pb.authStore.token}';
|
||||
request.headers['Authorization'] = 'Bearer ${PocketBaseService.authStore.token}';
|
||||
|
||||
// Send the request
|
||||
final response = await request.send();
|
||||
|
||||
@ -147,7 +147,7 @@ class _FeedbackFormState extends ConsumerState<FeedbackForm>
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
@ -1018,13 +1018,13 @@ class _FeedbackFormState extends ConsumerState<FeedbackForm>
|
||||
// final adminToken = adminAuth.token;
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
final response = await _pb
|
||||
.collection('feedback')
|
||||
.create(body: feedbackData, headers: {'Authorization': adminToken});
|
||||
.create(body: feedbackData, headers: {'Authorization': PocketBaseService.authStore.token});
|
||||
if (response != null) {
|
||||
final createdTime = response.created;
|
||||
// Send email
|
||||
|
||||
@ -71,10 +71,10 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
|
||||
// );
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
final result = await _pb.collection('users').getFullList(
|
||||
filter: 'role="user"',
|
||||
);
|
||||
|
||||
@ -13,6 +13,7 @@ import 'package:uae_stat/config/theme/service.dart';
|
||||
import 'package:uae_stat/config/theme/theme_provider.dart';
|
||||
import 'package:uae_stat/config/toggle_lang_service.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/services/pocketbase_service.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
import '../../custom_drawer_routes.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@ -73,7 +74,7 @@ class _NotificationPageState extends ConsumerState<NotificationPage> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
@ -145,15 +146,15 @@ class _NotificationPageState extends ConsumerState<NotificationPage> {
|
||||
// final adminToken = adminAuth.token;
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
print('adminToken- ${adminToken}');
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
// print('adminToken- ${adminToken}');
|
||||
final userDetailsResponse = await _pb.collection('users').getOne(
|
||||
fetchedUserId!,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}',
|
||||
},
|
||||
);
|
||||
print('userDetails: $userDetailsResponse');
|
||||
@ -195,7 +196,7 @@ class _NotificationPageState extends ConsumerState<NotificationPage> {
|
||||
}
|
||||
|
||||
Future<void> fetchNotifications(locale) async {
|
||||
final baseUrl = apiUrl + '/api/getNotification';
|
||||
final baseUrl = apiUrl + 'api/getNotification';
|
||||
try {
|
||||
final response = await http.get(Uri.parse('$baseUrl?language=$locale'),
|
||||
headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'});
|
||||
@ -653,10 +654,10 @@ Future<void> readedNotification(
|
||||
// );
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
|
||||
final url =
|
||||
"${pb.baseUrl}api/removeNotification?user_id=$userId¬ification_id=$notificationId";
|
||||
@ -666,7 +667,7 @@ Future<void> readedNotification(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Add this
|
||||
'Authorization': pb.authStore.token, // Correct way to send auth token
|
||||
'Authorization': PocketBaseService.authStore.token, // Correct way to send auth token
|
||||
'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'
|
||||
},
|
||||
);
|
||||
|
||||
@ -86,7 +86,7 @@ class _NotificationDetailsState extends ConsumerState<NotificationDetails> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
@ -112,7 +112,7 @@ class _NotificationDetailsState extends ConsumerState<NotificationDetails> {
|
||||
|
||||
Future<void> fetchNotifications(locale) async {
|
||||
notificationID = widget.id;
|
||||
final baseUrl = apiUrl + '/api/getNotification';
|
||||
final baseUrl = apiUrl + 'api/getNotification';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse('$baseUrl?language=$locale&id=$notificationID'),
|
||||
|
||||
@ -47,7 +47,7 @@ class _aboutFCSCState extends ConsumerState<aboutFCSC> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -47,7 +47,7 @@ class _GetStartedState extends ConsumerState<GetStarted> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -50,7 +50,7 @@ class _AppFeaturesState extends ConsumerState<AppFeatures> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -48,7 +48,7 @@ class _ChangeMyPasswordState extends ConsumerState<ChangeMyPassword> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -48,7 +48,7 @@ class _EditMyProfileState extends ConsumerState<EditMyProfile> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -49,7 +49,7 @@ class _HowUseTheAppState extends ConsumerState<HowUseTheApp> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -51,7 +51,7 @@ class _PurposeState extends ConsumerState<Purpose> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -51,7 +51,7 @@ class _StayUpdateState extends ConsumerState<StayUpdate> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -50,7 +50,7 @@ class _WhoUseTheAppState extends ConsumerState<WhoUseTheApp> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -50,7 +50,7 @@ class _aboutTheAppState extends ConsumerState<aboutTheApp> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -48,7 +48,7 @@ class _FAQPageState extends ConsumerState<FAQPage> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -51,7 +51,7 @@ class _UsingFeaturesState extends ConsumerState<UsingFeatures> {
|
||||
}
|
||||
|
||||
Future<void> fetchData(locale, themeMode) async {
|
||||
const baseUrl = '$apiUrl/api/getUAENumbersData';
|
||||
const baseUrl = '${apiUrl}api/getUAENumbersData';
|
||||
try {
|
||||
final response = await http.get(
|
||||
Uri.parse(baseUrl + '?language=$locale&color_mode=$themeMode'),
|
||||
|
||||
@ -24,6 +24,7 @@ import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/bottom_bar_asset_icon_path.dart';
|
||||
import 'package:uae_stat/infrastructure/services/img_asset_paths/icons/drawer_asset_icon_path.dart';
|
||||
import 'package:uae_stat/infrastructure/services/pocketbase_service.dart';
|
||||
import 'package:uae_stat/l10n/app_localizations.dart';
|
||||
|
||||
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
|
||||
@ -714,14 +715,14 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
//print('adminToken- ${adminToken}');
|
||||
|
||||
final themeService = ThemeBaseService();
|
||||
final adminToken = await themeService.getAdminToken(
|
||||
email: auth.email,
|
||||
password: auth.password,
|
||||
);
|
||||
// final adminToken = await themeService.getAdminToken(
|
||||
// email: auth.email,
|
||||
// password: auth.password,
|
||||
// );
|
||||
final userDetailsResponse = await _pb.collection('users').getOne(
|
||||
userId!,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
'Authorization': 'Bearer ${PocketBaseService.authStore.token}',
|
||||
},
|
||||
);
|
||||
print('NAVuserDetails: $userDetailsResponse');
|
||||
@ -762,7 +763,7 @@ class _BaseScaffoldState extends ConsumerState<BaseScaffold> {
|
||||
}
|
||||
|
||||
Future<void> fetchNotifications(locale) async {
|
||||
final baseUrl = apiUrl + '/api/getNotification';
|
||||
final baseUrl = apiUrl + 'api/getNotification';
|
||||
try {
|
||||
final response = await http.get(Uri.parse('$baseUrl?language=$locale'),
|
||||
headers: {'APP_SIGNATURE': 'fcsc.gov.ae.X7pL9qZm2A'});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user