Repository navigation
fix(ldap): reactivate device session on LDAP login - #9673
Merged
okatu-loli merged 1 commit intoOct 21, 2026
Merged
Conversation
LDAP login (loginLdap) does not call device.EnsureActiveOnLogin, unlike the password login path (loginHash). After a user logs out, their device session is marked inactive. Logging in again via LDAP then returns a token successfully, but every subsequent request (e.g. /api/me) fails with 401 "session inactive" because the session is never reactivated. Add the missing EnsureActiveOnLogin call and return device_key in the response, matching the password login flow.
skysliences
approved these changes
Oct 20, 2026
JoaHuang
approved these changes
Oct 21, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Logging in via LDAP fails with a "session inactive" error after the user has logged out once. The login request itself succeeds (returns a token), but subsequent authenticated requests (e.g.
/api/me) return401 session inactive, so the user ends up logged out immediately — the frontend shows both a "login success" and a "session inactive" prompt.Root Cause
The LDAP login handler
loginLdapdoes not calldevice.EnsureActiveOnLogin, unlike the password login handlerloginHash. When a user logs out, their device session is marked inactive. Logging in again via LDAP never reactivates that session, so the token is bound to an inactive session and the auth middleware (HandleSession→device.Handle) rejects follow-up requests witherrs.SessionInactive(401).This is the same class of issue that was fixed for the SSO login path.
Fix
Add the missing
device.EnsureActiveOnLogincall inloginLdapand returndevice_keyin the response, matching the password login flow:user.IDandClient-Id(identical tologinHash).device.EnsureActiveOnLogin(user.ID, key, userAgent, clientIP)before generating the token, handlingerrs.TooManyDeviceswith 403 like the password path.device_keyalongsidetoken.Verification
go build ./server/handles/passesgofmtclean