Skip to content

Commit

Permalink
Fix userType (Fixed SignUp and LogIn) (#2389) (#2435)
Browse files Browse the repository at this point in the history
* Bump syncfusion_flutter_calendar from 24.2.3 to 24.2.4 (#2382)

Bumps [syncfusion_flutter_calendar](https://github.com/syncfusion/flutter-widgets/tree/master/packages) from 24.2.3 to 24.2.4.
- [Release notes](https://github.com/syncfusion/flutter-widgets/releases)
- [Commits](https://github.com/syncfusion/flutter-widgets/commits/HEAD/packages)

---
updated-dependencies:
- dependency-name: syncfusion_flutter_calendar
  dependency-type: direct:production
  update-type: version-update:semver-patch
...




* Bump url_launcher_platform_interface from 2.3.1 to 2.3.2 (#2381)

Bumps [url_launcher_platform_interface](https://github.com/flutter/packages/tree/main/packages/url_launcher) from 2.3.1 to 2.3.2.
- [Release notes](https://github.com/flutter/packages/releases)
- [Commits](https://github.com/flutter/packages/commits/url_launcher_platform_interface-v2.3.2/packages/url_launcher)

---
updated-dependencies:
- dependency-name: url_launcher_platform_interface
  dependency-type: direct:production
  update-type: version-update:semver-patch
...




* Bump geolocator from 10.1.0 to 11.0.0 (#2378)

Bumps [geolocator](https://github.com/baseflow/flutter-geolocator) from 10.1.0 to 11.0.0.
- [Commits](Baseflow/flutter-geolocator@geolocator_v10.1.0...geolocator_v11.0.0)

---
updated-dependencies:
- dependency-name: geolocator
  dependency-type: direct:production
  update-type: version-update:semver-major
...




* Bump permission_handler from 11.2.1 to 11.3.0 (#2379)

Bumps [permission_handler](https://github.com/baseflow/flutter-permission-handler) from 11.2.1 to 11.3.0.
- [Commits](Baseflow/flutter-permission-handler@permission_handler_v11.2.1...permission_handler_v11.3.0)

---
updated-dependencies:
- dependency-name: permission_handler
  dependency-type: direct:production
  update-type: version-update:semver-minor
...




* Upgraded github actions to the latest versions (#2385)



* Remove the geolocator package (#2388)

* added additional test cases to edit profile page test file (#2331)

* added additional test cases to edit profile page test file

* updates the code

* fixed failing tests

* fixed

* Done some corrections in previous code

* Update edit_profile_page_test.dart

* Update edit_profile_page_test.dart

* Made some changes to run the tests

Made some changes to run the tests

* Fix UserType

* Fixing linting errors

* Fixing linting errors

* Fixing minor errors

* Fixing failing tests

* Fixing failing tests

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Parag Gupta <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Peter Harrison <[email protected]>
Co-authored-by: Peter Harrison <[email protected]>
Co-authored-by: Yousef Rabia <[email protected]>
Co-authored-by: Insiya <[email protected]>
  • Loading branch information
7 people authored Mar 23, 2024
1 parent 0188720 commit 0cd07d5
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 89 deletions.
93 changes: 79 additions & 14 deletions lib/models/user/user_info.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// ignore_for_file: talawa_api_doc, use_setters_to_change_properties
// ignore_for_file: talawa_good_doc_comments
// ignore_for_file: use_setters_to_change_properties

import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
Expand Down Expand Up @@ -27,11 +26,15 @@ class User extends HiveObject {

factory User.fromJson(Map<String, dynamic> json1, {bool fromOrg = false}) {
Map<String, dynamic> json;
Map<String, dynamic>? appUserProfile;
if (fromOrg) {
json = json1;
appUserProfile = json1;
} else {
json = json1['user'] as Map<String, dynamic>;
appUserProfile = json1['appUserProfile'] as Map<String, dynamic>?;
}

return User(
authToken: fromOrg ? ' ' : json1['accessToken'] as String?,
refreshToken: fromOrg ? ' ' : json1['refreshToken'] as String?,
Expand All @@ -41,24 +44,24 @@ class User extends HiveObject {
lastName: json['lastName'] != null ? json['lastName'] as String? : null,
email: json['email'] != null ? json['email'] as String? : null,
image: json['image'] != null ? json['image'] as String? : null,
adminFor: json['adminFor'] != null
? (json['adminFor'] as List<dynamic>?)
?.map((e) => OrgInfo.fromJson(e as Map<String, dynamic>))
adminFor: appUserProfile?['adminFor'] != null
? (appUserProfile!['adminFor'] as List<dynamic>)
.map((e) => OrgInfo.fromJson(e as Map<String, dynamic>))
.toList()
: null,
createdOrganizations: json['createdOrganizations'] != null
? (json['createdOrganizations'] as List<dynamic>?)
?.map((e) => OrgInfo.fromJson(e as Map<String, dynamic>))
createdOrganizations: appUserProfile?['createdOrganizations'] != null
? (appUserProfile!['createdOrganizations'] as List<dynamic>)
.map((e) => OrgInfo.fromJson(e as Map<String, dynamic>))
.toList()
: null,
joinedOrganizations: json['joinedOrganizations'] != null
? (json['joinedOrganizations'] as List<dynamic>?)
?.map((e) => OrgInfo.fromJson(e as Map<String, dynamic>))
? (json['joinedOrganizations'] as List<dynamic>)
.map((e) => OrgInfo.fromJson(e as Map<String, dynamic>))
.toList()
: null,
membershipRequests: json['membershipRequests'] != null
? (json['membershipRequests'] as List<dynamic>?)
?.map(
? (json['membershipRequests'] as List<dynamic>)
.map(
(e) => OrgInfo.fromJson(
e as Map<String, dynamic>,
memberRequest: true,
Expand All @@ -68,7 +71,14 @@ class User extends HiveObject {
: null,
);
}
//Method to print the User details.

/// Method to print the User details.
///
/// **params**:
/// None
///
/// **returns**:
/// None
void print() {
debugPrint('authToken: ${this.authToken}');
debugPrint('refreshToken: ${this.refreshToken}');
Expand All @@ -83,46 +93,101 @@ class User extends HiveObject {
debugPrint('membershipRequests: ${this.membershipRequests}');
}

/// HiveField for authToken.
@HiveField(0)
String? authToken;

/// HiveField for refreshToken.
@HiveField(1)
String? refreshToken;

/// HiveField for userID.
@HiveField(2)
String? id;

/// HiveField for user's first name.
@HiveField(3)
String? firstName;

/// HiveField for user's last name.
@HiveField(4)
String? lastName;

/// HiveField for user's Email.
@HiveField(5)
String? email;

/// HiveField for user's avatar.
@HiveField(6)
String? image;

/// /// HiveField for all organisations joined by user.
@HiveField(7)
List<OrgInfo>? joinedOrganizations = [];

/// HiveField for all organisations created by user.
@HiveField(8)
List<OrgInfo>? createdOrganizations = [];

/// HiveField for all organisations user is admin of.
@HiveField(9)
List<OrgInfo>? adminFor = [];

/// HiveField for all organisations user has sent membership request.
@HiveField(10)
List<OrgInfo>? membershipRequests = [];

/// Method to updated joinedOrganisation list.
///
/// **params**:
/// * `orgList`: List of organsaitions user has joined.
///
/// **returns**:
/// None
void updateJoinedOrg(List<OrgInfo> orgList) {
this.joinedOrganizations = orgList;
}

/// Method to updated createdOrganisation list.
///
/// **params**:
/// * `orgList`: List of organsaitions user has created.
///
/// **returns**:
/// None
void updateCreatedOrg(List<OrgInfo> orgList) {
this.createdOrganizations = orgList;
}

/// Method to update membershipRequests List.
///
/// **params**:
/// * `orgList`: List of organisations user have sent membership request.
///
/// **returns**:
/// None
void updateMemberRequestOrg(List<OrgInfo> orgList) {
this.membershipRequests = [...membershipRequests!, ...orgList];
}

/// Method to update adminFor List.
///
/// **params**:
/// * `orgList`: List of organisations user is admin of.
///
/// **returns**:
/// None
void updateAdminFor(List<OrgInfo> orgList) {
this.adminFor = orgList;
}

//Method to update the user details.
/// Method to update the user details.
///
/// **params**:
/// * `details`: updated user Info/details
///
/// **returns**:
/// None
void update(User details) {
this.firstName = details.firstName;
this.lastName = details.lastName;
Expand Down
5 changes: 1 addition & 4 deletions lib/services/user_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class UserConfig {
_currentUser = User(id: 'null', authToken: 'null');
return false;
}

databaseFunctions.initClientNonAuth();
await sessionManager.refreshSession();
// generate access token
Expand All @@ -102,16 +101,14 @@ class UserConfig {
final List users = result.data!['users'] as List;
final User userInfo = User.fromJson(
users[0] as Map<String, dynamic>,
fromOrg: true,
fromOrg: false,
);
userInfo.authToken = userConfig.currentUser.authToken;
userInfo.refreshToken = userConfig.currentUser.refreshToken;
userConfig.updateUser(userInfo);
_currentOrg ??= _currentUser!.joinedOrganizations![0];
_currentOrgInfoController.add(_currentOrg!);

saveUserInHive();

return true;
} on Exception catch (e) {
print(e);
Expand Down
Loading

0 comments on commit 0cd07d5

Please sign in to comment.