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

Log out after 12 hours #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

alexsapps
Copy link
Collaborator

After a Google account is disabled or password reset, we need ADB access to expire in less than 30 days which is the current behavior. However, this change avoids expiring the session too quickly in order to avoid data loss until we can set up sessions to renew automatically before they expire if the user is still working or verify this is already happening.

After a Google account is disabled or password reset, we need ADB access to expire in less than 30 days which is the current behavior. However, this change avoids expiring the session too quickly in order to avoid data loss until we can set up sessions to renew automatically before they expire if the user is still working or verify this is already happening.
Copy link
Member

@jakehobbs jakehobbs left a comment

Choose a reason for hiding this comment

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

lgtm but you are gonna make almira's life harder 😆

@alexsapps
Copy link
Collaborator Author

Still thinking about this. In an emergency we could shut down the ADB and start it back up with different keys, and I don't want someone to be in the middle of taking attendance without any indication that their session is expiring imminently.

@alexsapps
Copy link
Collaborator Author

(In addition to rotating the server key in the event of an emergency) Maybe we can make the cookie expire at 5AM to avoid people getting signed out while trying to do something like taking attendance. Might update this PR for that eventually.

ChatGPT and I co-authored this function (not tested)

package main

import (
	"fmt"
	"time"
)

func next5AMPTAfter24Hours() time.Time {
	// Get the current time in PT
	loc, err := time.LoadLocation("America/Los_Angeles")
	if err != nil {
		panic(err)
	}
	now := time.Now().In(loc)

	// Calculate 5 AM PT tomorrow
	tomorrow := now.AddDate(0, 0, 1)
	tomorrow5AM := time.Date(tomorrow.Year(), tomorrow.Month(), tomorrow.Day(), 5, 0, 0, 0, loc)

	// If tomorrow's 5 AM PT is more than 24 hours from now, use it
	if tomorrow5AM.After(now.Add(24 * time.Hour)) {
		return tomorrow5AM
	}

	// Otherwise, calculate 5 AM PT the day after tomorrow
	dayAfterTomorrow := now.AddDate(0, 0, 2)
	dayAfterTomorrow5AM := time.Date(dayAfterTomorrow.Year(), dayAfterTomorrow.Month(), dayAfterTomorrow.Day(), 5, 0, 0, 0, loc)

	return dayAfterTomorrow5AM
}

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.

2 participants