forked from PalisadoesFoundation/talawa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created Session Management. (PalisadoesFoundation#2362)
* feat: efficient session management * chore: run check ignore * Revert "chore: run check ignore" This reverts commit be7e49f. * chore fix: run check ignore * feat: added new package fake_async * chore: fixed codecov drop * Update README.md * Deprecate Google Maps Integration (PalisadoesFoundation#2363) * Post comments were invisible in Individual Post Page with Image (PalisadoesFoundation#2350) * Fixed Comment * Fixed Comment * Fixed Comment * Fixed Comment * Fixed Comment * Bump syncfusion_flutter_datepicker from 24.1.47 to 24.2.3 (PalisadoesFoundation#2365) Bumps [syncfusion_flutter_datepicker](https://github.com/syncfusion/flutter-widgets/tree/master/packages) from 24.1.47 to 24.2.3. - [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_datepicker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump syncfusion_flutter_calendar from 24.1.45 to 24.2.3 (PalisadoesFoundation#2367) Bumps [syncfusion_flutter_calendar](https://github.com/syncfusion/flutter-widgets/tree/master/packages) from 24.1.45 to 24.2.3. - [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-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fixed requested changes * pulled latest upstream --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Peter Harrison <[email protected]> Co-authored-by: Parag Gupta <[email protected]> Co-authored-by: Shivam Gupta <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1110aef
commit 69e6513
Showing
21 changed files
with
227 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:talawa/locator.dart'; | ||
|
||
/// Manages user sessions and periodically refreshes access tokens. | ||
class SessionManager { | ||
SessionManager() { | ||
initializeSessionRefresher(); | ||
} | ||
|
||
/// returns refresh interval of Session Manager. | ||
int get refreshInterval => _refreshInterval; | ||
|
||
/// refresh interval in seconds. | ||
static const int _refreshInterval = 600; | ||
|
||
/// Initializes as session refresher. | ||
/// | ||
/// Invokes [refreshSession] periodically at regular | ||
/// refresh intervals. | ||
/// | ||
/// **params**: | ||
/// None | ||
/// | ||
/// **returns**: | ||
/// * `Timer`: refresh timer. | ||
Timer initializeSessionRefresher() { | ||
return Timer.periodic( | ||
const Duration(seconds: _refreshInterval), | ||
(Timer timer) async { | ||
refreshSession(); | ||
}, | ||
); | ||
} | ||
|
||
/// Asynchronously refreshes the user session. | ||
/// | ||
/// **params**: | ||
/// None | ||
/// | ||
/// **returns**: | ||
/// * `Future<bool>`: indicates if session refresh was | ||
/// successful. | ||
Future<bool> refreshSession() async { | ||
if (userConfig.loggedIn && userConfig.currentUser.refreshToken != null) { | ||
final refreshed = await databaseFunctions | ||
.refreshAccessToken(userConfig.currentUser.refreshToken!); | ||
return refreshed; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.