8000 🐛 Bug Report: `expire` is empty from `account.listSessions()` · Issue #4846 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

🐛 Bug Report: expire is empty from account.listSessions() #4846

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

Closed
2 tasks done
devcat-net opened this issue Dec 12, 2022 · 5 comments · Fixed by #5562
Closed
2 tasks done

🐛 Bug Report: expire is empty from account.listSessions() #4846

devcat-net opened this issue Dec 12, 2022 · 5 comments · Fixed by #5562
Assignees
Labels
bug Something isn't working good first issue Good for newcomers product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.
Milestone

Comments

@devcat-net
Copy link

👟 Reproduction steps

I am implementing a Vue.js application in which I am using the appwrite SDK v. 10.1.0. The appwrite version is 1.1.2. I updated both the SDK and the appwrite version together, and now I am facing the problem that when I send a listSessions request to the backend, I don't get a value for the expire field. As you can see in the screenshot, I receive data, but the expire field is an empty string.

grafik

👍 Expected behavior

I expect an ISO-formatted Date string

👎 Actual Behavior

I receive an empty string.

🎲 Appwrite version

Version 1.1.x

💻 Operating system

Linux

🧱 Your Environment

Appwrite v. 1.1.2
Web SDK v 10.1.0

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@devcat-net devcat-net added the bug Something isn't working label Dec 12, 2022
@stnguyen90 stnguyen90 changed the title 🐛 Bug Report: 🐛 Bug Report: expire is empty from account.listSessions() Dec 12, 2022
@stnguyen90 stnguyen90 added the product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services. label Dec 12, 2022
@stnguyen90
Copy link
Contributor
stnguyen90 commented Dec 12, 2022

@devcat-net, thanks for creating this issue! 🙏🏼 We changed how we handled the expiration and now calculate it at runtime like:

foreach ($sessions as $session) {/** @var Document $session */
if ($sessionId == $session->getId()) {
$countryName = $locale->getText('countries.' . strtolower($session->getAttribute('countryCode')), $locale->getText('locale.country.unknown'));
$session
->setAttribute('current', ($session->getAttribute('secret') == Auth::hash(Auth::$secret)))
->setAttribute('countryName', $countryName)
->setAttribute('expire', DateTime::addSeconds(new \DateTime($session->getCreatedAt()), $authDuration))
;
return $response->dynamic($session, Response::MODEL_SESSION);
}
}

Looks like we forgot to add that calculation in List Sessions:

foreach ($sessions as $key => $session) {/** @var Document $session */
$countryName = $locale->getText('countries.' . strtolower($session->getAttribute('countryCode')), $locale->getText('locale.country.unknown'));
$session->setAttribute('countryName', $countryName);
$session->setAttribute('current', ($current == $session->getId()) ? true : false);
$sessions[$key] = $session;
}

@CoderMayhem
Copy link

Hey @stnguyen90, I've implemented the suggested change, but can't figure out a way to test it locally. Any help would be much appreciated on the PR.

8000

@stnguyen90
Copy link
Contributor

Hey @stnguyen90, I've implemented the suggested change, but can't figure out a way to test it locally. Any help would be much appreciated on the PR.

You should be able to manually make the API call to test. In addition, you should add a test case to make sure we don't run into the problem again.

@fanatic75
Copy link
Contributor
fanatic75 commented May 19, 2023

@stnguyen90, I guess the assignee wasn't working. I have fixed the bug and added the assertion in the test case. Please review
Also you can please assign bug to me

@stnguyen90
Copy link
Contributor

@CoderMayhem, are you still working on this or can I unassign you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.
Projects
None yet
4 participants
0