Skip to content

If session persistent and current date not equal to last_login, update last_login date on every dashboard reload

Christian Walgenbach requested to merge relogin into master

Closes #1116 (closed) and #956 (closed)

Reason why we need this change?

The automatic logout is just annoying and we regularly get support requests about it. The only reason we have done it this way is to keep the "Last Login" date for the Foodsaver page up to date, so that Ambassadors, Foodsaver who have not logged in again for more than 6 months, can be removed from the district.

What does this MR do?

  • renamed last_login variable to last_activity
  • added alias last_activity to select statements in gateway classes
  • added function updateLastActivity to Session.php, which will be called from dashboard every time page is reloaded
  • In updateLastActivity the date from the session and the current date is normalized to YYYY-MM-DD. If the session is persistent and today's date is not equal to the last_activity, then the date is updated in the database and session.

How confident are you it won't break things if deployed?

Links to related issues

https://yunity.slack.com/archives/C1T1ZM9A4/p1667031499877479

How to test

  1. Checkout branch locally
  2. Login as user2 (foodsaver) -> Set cookie "Stay logged in permanently"
  3. Login as userorga in a other brother or private session
  4. Change the last_login field in table fs_foodsaver for user2 to yesterday
  5. Add this code to src/Lib/Session.php in function updateLastActivity $this->refreshFromDatabase; dd();
  6. Reload dashboard for user2
  7. Check date for user2 in profil as orga user. it should yesterday.
  8. Remove or comment added code
  9. Reload dashboard for user2
  10. Check date for user2 in profil orga user. it should today.

Screenshots (if applicable)

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • set a "for:" label to indicate who will be affected by this change
  • added to the next milestone (see https://gitlab.com/foodsharing-dev/foodsharing/-/milestones, unless it has a "for:Dev" label)
  • added an entry to CHANGELOG.md
  • added a short text that can be used in the release notes
  • Once your MR has been merged, you are responsible to create a testing issue in the Beta Testing forum: https://foodsharing.de/?page=bezirk&bid=734&sub=forum. Please change the MRs label to "state:Beta testing".
    • Consider writing a detailed description in German.
    • Describe in a few sentences, what should be tested from a user perspective.
    • Also mention different settings (e.g. different browsers, roles, ...) how this change can be tested.
    • Be aware, that also non technical people should understand.

Release notes text in German

Wenn beim Login das Cookie auf "Dauerhaft eingeloggt bleiben" gesetzt wird, bleibt die Sitzung 14 Tage aktiv. Ansonsten weiterhin bleibt es bei 1 Tag. Der "letzte Login" wird jetzt als "Letzte Aktivität" angezeigt. Bei jedem Aufruf vom Dashboard wird das das Datum aktualisiert, wenn das Cookie "Dauerhaft eingeloggt bleiben" gesetzt wurde.

Edited by Christian Walgenbach

Merge request reports