Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sign user out after 2 hours/Never #514

Closed
wants to merge 22 commits into from
Closed

Conversation

fremartini
Copy link
Member

closes #169

@fremartini fremartini requested a review from a team October 3, 2023 06:24
@ghost
Copy link

ghost commented Oct 3, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (bc0fa26) 72.36% compared to head (fce0515) 73.77%.
Report is 2 commits behind head on main.

Files Patch % Lines
...sion/presentation/cubit/session_timeout_state.dart 63.63% 4 Missing ⚠️
...tion/presentation/cubits/authentication_cubit.dart 94.11% 2 Missing ⚠️
...res/session/data/models/session_details_model.dart 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #514      +/-   ##
==========================================
+ Coverage   72.36%   73.77%   +1.41%     
==========================================
  Files         133      140       +7     
  Lines        1603     1716     +113     
==========================================
+ Hits         1160     1266     +106     
- Misses        443      450       +7     
Flag Coverage Δ
unittests 73.77% <93.91%> (+1.41%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fremartini fremartini enabled auto-merge (squash) October 12, 2023 14:18
@fremartini fremartini changed the base branch from develop to main October 15, 2023 09:39
Copy link
Member

@marfavi marfavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature can be implemented with 5-10 changed files instead of 30. Remove any code refactoring from your feature branch before proceeding.

@fremartini fremartini requested a review from marfavi October 29, 2023 11:16
@fremartini fremartini marked this pull request as draft November 11, 2023 08:07
auto-merge was automatically disabled November 11, 2023 08:07

Pull request was converted to draft

@marfavi marfavi changed the title Sign user out after 2 hours/Never feat: sign user out after 2 hours/Never Nov 16, 2023
@fremartini
Copy link
Member Author

#552

@fremartini fremartini marked this pull request as ready for review November 27, 2023 15:49
@fremartini fremartini requested a review from a team November 27, 2023 15:50
@fremartini fremartini enabled auto-merge (squash) November 27, 2023 15:50
@fremartini fremartini enabled auto-merge (squash) December 7, 2023 17:57
@marfavi
Copy link
Member

marfavi commented Dec 9, 2023

I have a few thoughts:

AuthenticationCubit vs server-side

I see a few issues with tracking session timeouts locally within AuthenticationCubit:

  1. Right now, the session timeout depends on the device's time (dateService.currentDateTime). This could get tricky if someone's device time is off. I'm thinking a server-side solution might be more foolproof, as it keeps the time check consistent and out of the user's hands (and our code).

  2. The code checks for session expiration only when the app starts up (appStarted method). What if the app stays open past the session timeout? It might be better if the app could actively monitor the session status and log out automatically when time’s up, even if it's still running.

  3. Adding session timeout management into AuthenticationCubit increases code complexity by quite a bit. Handling this on the server-side might simplify our code and let AuthenticationCubit focus just whether the user is logged in or not.

I think tackling session timeouts on the server could really streamline things. It might also make features like "auto-logout after X inactive hours" easier to manage since the server would just reset the session timer with each valid request.

Other code considerations and UX

Also, about the changes to Dropdown and SettingListItem - they seem to be doing things a bit differently now. We should probably stick to keeping these components simple to avoid any unexpected behaviors. For instance, we don't want any complex behaviour in a setting list item - see how we open a new page for other settings that requires text input or a selection from a list. How the app handles session timeouts UX-wise also needs to be discussed before we try for a new implementation. For instance, does the user even need to be able to choose the expiration time themselves?

Next steps

I appreciate the effort you've put into this PR, but for now, I'm closing this PR. To get this feature up and running we should discuss the implementation details further in AnalogIO/analog-core#238 before attempting to implement this client-side.

@marfavi marfavi closed this Dec 9, 2023
auto-merge was automatically disabled December 9, 2023 14:58

Pull request was closed

@fremartini fremartini reopened this Dec 9, 2023
Copy link
Member

@marfavi marfavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address my previous comment.

final FilterCategory value;
final List<DropdownMenuItem<FilterCategory>>? items;
final void Function(FilterCategory?) onChanged;
final T value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give a more descriptive name for the type T

Suggested change
final T value;
final DropdownItem value;

Comment on lines +10 to +11
final TextStyle? textStyle;
final Color? dropdownColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make required with no default value. What I suspect you really want is a way to change the colour of the text, in which case you can also change the TextStyle field into a Color field instead.

Suggested change
final TextStyle? textStyle;
final Color? dropdownColor;
final Color textColor;
final Color dropdownColor;

@@ -9,22 +8,26 @@ class SettingListEntry extends StatelessWidget {
final bool destructive;
final void Function()? onTap;
final ListEntrySide sideToExpand;
final bool overrideDisableBehaviour;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't override intended disabling behavior.

void initSession() {
// bloc
const List<SessionTimeout> entries = [
('2 hours', Duration(hours: 2)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't put actual configuration data in the service locator

@@ -2,17 +2,21 @@ import 'package:coffeecard/core/styles/app_colors.dart';
import 'package:coffeecard/core/styles/app_text_styles.dart';
import 'package:flutter/material.dart';

class Dropdown<FilterCategory> extends StatelessWidget {
class Dropdown<T> extends StatelessWidget {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change the intended use case for this widget.

@marfavi marfavi closed this Mar 6, 2024
@marfavi marfavi deleted the frem/sign_out_timer branch March 6, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User should reenter his PIN code after 2 hours of inactivity
3 participants