forked from firka/student-legacy
also added test accounts to dev branch
This commit is contained in:
parent
fa75c1ec06
commit
a11ebce6fb
@ -53,9 +53,14 @@ class FilcAPI {
|
||||
.map((json) => School.fromJson(json))
|
||||
.toList();
|
||||
schools.add(School(
|
||||
city: "Tiszabura",
|
||||
instituteCode: "supporttest-reni-tiszabura-teszt01",
|
||||
name: "FILC Éles Reni tiszabura-teszt",
|
||||
city: "Stockholm",
|
||||
instituteCode: "refilc-test-sweden",
|
||||
name: "reFilc Test SE - Leo Ekström High School",
|
||||
));
|
||||
schools.add(School(
|
||||
city: "Madrid",
|
||||
instituteCode: "refilc-test-spain",
|
||||
name: "reFilc Test ES - Emilio Obrero University",
|
||||
));
|
||||
return schools;
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
// ignore_for_file: avoid_print, use_build_context_synchronously
|
||||
|
||||
import 'package:filcnaplo/utils/jwt.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/school.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/event_provider.dart';
|
||||
import 'package:filcnaplo_kreta_api/providers/exam_provider.dart';
|
||||
@ -20,6 +21,7 @@ import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:filcnaplo/api/nonce.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
enum LoginState {
|
||||
missingFields,
|
||||
@ -47,6 +49,56 @@ Future loginAPI({
|
||||
void Function(User)? onLogin,
|
||||
void Function()? onSuccess,
|
||||
}) async {
|
||||
Future testLogin(School school) async {
|
||||
var user = User(
|
||||
username: username,
|
||||
password: password,
|
||||
instituteCode: instituteCode,
|
||||
name: 'Teszt Lajos',
|
||||
student: Student(
|
||||
birth: DateTime.now(),
|
||||
id: const Uuid().v4(),
|
||||
name: 'Teszt Lajos',
|
||||
school: school,
|
||||
yearId: '1',
|
||||
parents: ['Teszt András', 'Teszt Linda'],
|
||||
),
|
||||
role: Role.parent,
|
||||
);
|
||||
|
||||
if (onLogin != null) onLogin(user);
|
||||
|
||||
// store test user in db
|
||||
await Provider.of<DatabaseProvider>(context, listen: false)
|
||||
.store
|
||||
.storeUser(user);
|
||||
Provider.of<UserProvider>(context, listen: false).addUser(user);
|
||||
Provider.of<UserProvider>(context, listen: false).setUser(user.id);
|
||||
|
||||
if (onSuccess != null) onSuccess();
|
||||
|
||||
return LoginState.success;
|
||||
}
|
||||
|
||||
// if institute matches one of test things do test login
|
||||
if (instituteCode == 'refilc-test-sweden') {
|
||||
School school = School(
|
||||
city: "Stockholm",
|
||||
instituteCode: "refilc-test-sweden",
|
||||
name: "reFilc Test SE - Leo Ekström High School",
|
||||
);
|
||||
|
||||
await testLogin(school);
|
||||
} else if (instituteCode == 'refilc-test-spain') {
|
||||
School school = School(
|
||||
city: "Madrid",
|
||||
instituteCode: "refilc-test-spain",
|
||||
name: "reFilc Test ES - Emilio Obrero University",
|
||||
);
|
||||
|
||||
await testLogin(school);
|
||||
} else {
|
||||
// normal login from here
|
||||
Provider.of<KretaClient>(context, listen: false).userAgent =
|
||||
Provider.of<SettingsProvider>(context, listen: false).config.userAgent;
|
||||
|
||||
@ -129,5 +181,7 @@ Future loginAPI({
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return LoginState.failed;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user