added zwg support

This commit is contained in:
Prince
2026-06-17 14:42:46 +02:00
parent cc4b02f3c9
commit 64eaa38079
12 changed files with 324 additions and 247 deletions

View File

@@ -0,0 +1,18 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import '../../models/user_model.dart';
class AuthProvider {
// get the user model from shared preferences
static Future<UserModel?> getUserModel() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String? userModelString = prefs.getString("userModel");
if (userModelString != null) {
Map<String, dynamic> userModelJson = jsonDecode(userModelString);
return UserModel.fromJson(userModelJson);
}
return null;
}
}

View File

@@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:qpay/auth_state.dart';
@@ -5,6 +7,8 @@ import 'package:qpay/http/http.dart';
import 'package:qpay/models/api_response.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../models/user_model.dart';
class LoginScreenModel {
String username = "";
String password = "";
@@ -72,6 +76,9 @@ class LoginController extends ChangeNotifier {
: ''),
);
UserModel userModel = UserModel.fromJson(response);
prefs.setString("userModel", jsonEncode(userModel));
// Notify the router that the user is now signed in so any
// auth-gated redirects (e.g. the groups flow) are re-evaluated
// and the user is sent to their originally requested page.