+fix
This commit is contained in:
@@ -8,6 +8,7 @@ class AuthService {
|
||||
AuthService({http.Client? client}) : _client = client ?? http.Client();
|
||||
|
||||
Future<String> login(String login, String password) async {
|
||||
print(ApiConfig.loginUrl);
|
||||
final response = await _client.post(
|
||||
Uri.parse(ApiConfig.loginUrl),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@@ -17,6 +18,8 @@ class AuthService {
|
||||
if (response.statusCode == 200) {
|
||||
return response.body;
|
||||
} else {
|
||||
print(response.statusCode);
|
||||
print(response.body);
|
||||
throw Exception('Invalid credentials');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SettingsService {
|
||||
SettingsService(){initialize();}
|
||||
static const String _baseUrlKey = 'server_base_url';
|
||||
static const String _defaultBaseUrl =
|
||||
'https://family-safety.onrender.com/api';
|
||||
@@ -13,6 +12,7 @@ class SettingsService {
|
||||
String get baseUrl => _baseUrl;
|
||||
String? login;
|
||||
String? pwd;
|
||||
bool loggedIn=false;
|
||||
|
||||
Future<void> initialize() async {
|
||||
if (_initialized) return;
|
||||
@@ -34,7 +34,14 @@ class SettingsService {
|
||||
pwd = pass;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(_loginKey, user);
|
||||
await prefs.setString(_loginKey, user);
|
||||
await prefs.setString(_pwdKey, pass);
|
||||
}
|
||||
Future<void> logOut() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
login = null;
|
||||
pwd = null;
|
||||
await prefs.remove(_loginKey);
|
||||
await prefs.remove(_pwdKey);
|
||||
}
|
||||
|
||||
void resetToDefault() {
|
||||
|
||||
Reference in New Issue
Block a user