Skip to content

Commit

Permalink
Merge pull request #26 from AdrianMargineanu/subgroup
Browse files Browse the repository at this point in the history
Subgroup
IoanaAlexandru authored Sep 14, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents ede657a + 3ea73e4 commit d83dd62
Showing 5 changed files with 203 additions and 61 deletions.
2 changes: 2 additions & 0 deletions lib/authentication/model/user.dart
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ class User {
String year;
String series;
String group;
String subgroup;

int permissionLevel;

@@ -23,6 +24,7 @@ class User {
this.year,
this.series,
this.group,
this.subgroup,
int permissionLevel})
: this.permissionLevel = permissionLevel ?? 0;

12 changes: 10 additions & 2 deletions lib/authentication/service/auth_provider.dart
Original file line number Diff line number Diff line change
@@ -29,12 +29,14 @@ extension DatabaseUser on User {
String year;
String series;
String group;
String subgroup;
if (snap.data.containsKey('class')) {
degree = snap.data['class']['degree'];
domain = snap.data['class']['domain'];
year = snap.data['class']['year'];
series = snap.data['class']['series'];
group = snap.data['class']['group'];
subgroup = snap.data['class']['subgroup'];
}

return User(
@@ -46,6 +48,7 @@ extension DatabaseUser on User {
year: year,
series: series,
group: group,
subgroup: subgroup,
permissionLevel: snap.data['permissionLevel']);
}

@@ -56,6 +59,7 @@ extension DatabaseUser on User {
if (year != null) classInfo['year'] = year;
if (series != null) classInfo['series'] = series;
if (group != null) classInfo['group'] = group;
if (subgroup != null) classInfo['subgroup'] = subgroup;

return {
'name': {'first': firstName, 'last': lastName},
@@ -342,6 +346,8 @@ class AuthProvider with ChangeNotifier {
filter.localizedLevelNames[3][LocaleProvider.localeString]);
String group = info.getIfPresent(
filter.localizedLevelNames[4][LocaleProvider.localeString]);
String subgroup = info.getIfPresent(
filter.localizedLevelNames[5][LocaleProvider.localeString]);

if (email == null || email == '') {
AppToast.show(S.of(context).errorInvalidEmail);
@@ -362,7 +368,8 @@ class AuthProvider with ChangeNotifier {
AppToast.show(S.of(context).errorMissingLastName);
return false;
}
if (!await AppValidator.isStrongPassword(password: password, context: context)) {
if (!await AppValidator.isStrongPassword(
password: password, context: context)) {
return false;
}

@@ -388,7 +395,8 @@ class AuthProvider with ChangeNotifier {
domain: domain,
year: year,
series: series,
group: group);
group: group,
subgroup: subgroup);

DocumentReference ref =
Firestore.instance.collection('users').document(user.uid);
1 change: 0 additions & 1 deletion lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d83dd62

Please sign in to comment.