feat: added authentification and redirection
This commit is contained in:
parent
1c9c5ce5fe
commit
ef641d4023
24 changed files with 731 additions and 173 deletions
24
lib/ui/auth/viewmodel/login_view_model.dart
Normal file
24
lib/ui/auth/viewmodel/login_view_model.dart
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:seshat/data/repositories/auth_repository.dart';
|
||||
import 'package:seshat/utils/command.dart';
|
||||
import 'package:seshat/utils/result.dart';
|
||||
|
||||
class LoginViewModel extends ChangeNotifier {
|
||||
LoginViewModel({required AuthRepository authRepository})
|
||||
: _authRepository = authRepository {
|
||||
login = Command1<void, (String username, String password)>(_login);
|
||||
}
|
||||
|
||||
final AuthRepository _authRepository;
|
||||
|
||||
late Command1 login;
|
||||
|
||||
Future<Result<void>> _login((String, String) credentials) async {
|
||||
final (username, password) = credentials;
|
||||
final result = await _authRepository.login(username, password);
|
||||
if (result is Error<void>) {
|
||||
debugPrint("Hehe no");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in a new issue