Robo-advisory-dart/lib/providers/auth_provider.dart

50 lines
1.2 KiB
Dart
Raw Normal View History

import 'dart:async';
import 'package:flutter/material.dart';
enum Status {
NotLoggedIn,
NotRegistered,
LoggedIn,
Registered,
Authenticating,
Registering,
LoggedOut
}
class AuthProvider with ChangeNotifier {
Status _loggedInStatus = Status.NotLoggedIn;
Status _registeredInStatus = Status.NotRegistered;
Status get loggedInStatus => _loggedInStatus;
Status get registeredInStatus => _registeredInStatus;
2022-09-11 14:37:28 +00:00
Future login(String email, int pinCode) async {
var result;
final Map<String, dynamic> loginData = {
'user': {'email': email, 'pinCode': pinCode}
};
_loggedInStatus = Status.Authenticating;
notifyListeners();
Timer(Duration(seconds: 30), () {
_loggedInStatus = Status.LoggedIn;
notifyListeners();
result = {'status': true, 'message': 'Successful'};
return result;
});
}
Future<Map<String, dynamic>> register(
String email, String password, String passwordConfirmation) async {
final Map<String, dynamic> registrationData = {
'user': {
'email': email,
'password': password,
'password_confirmation': passwordConfirmation
}
};
return {'status': true, 'message': 'Successfully registered'};
}
}