mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
fix concurrency issue when checking session ID (#14)
Co-authored-by: Tak Wai Wong <tak@hntlabs.com>
This commit is contained in:
parent
414c272bc0
commit
3494cabafd
|
|
@ -156,6 +156,13 @@ func (d *sessionsDict) startTimer(duration time.Duration, sessionID string) {
|
|||
})
|
||||
}
|
||||
|
||||
func (d *sessionsDict) hasSession(sessionID string) bool {
|
||||
d.RLock()
|
||||
defer d.RUnlock()
|
||||
_, ok := d.sessions[sessionID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// addCompletedSessionStage records that a session has completed an auth stage
|
||||
// also starts a timer to delete the session once done.
|
||||
func (d *sessionsDict) addCompletedSessionStage(sessionID string, stage authtypes.LoginType) {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func handlePublicKeyRegistration(
|
|||
return false, authtypes.LoginStagePublicKeyNewRegistration, nil
|
||||
}
|
||||
|
||||
if _, ok := sessions.sessions[authHandler.GetSession()]; !ok {
|
||||
if !sessions.hasSession(authHandler.GetSession()) {
|
||||
return false, "", &util.JSONResponse{
|
||||
Code: http.StatusUnauthorized,
|
||||
JSON: jsonerror.Unknown("the session ID is missing or unknown."),
|
||||
|
|
|
|||
Loading…
Reference in a new issue