added zwg support
This commit is contained in:
18
lib/screens/onboarding/auth_provider.dart
Normal file
18
lib/screens/onboarding/auth_provider.dart
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user