legacyprovisioning: add check for auth key on logout

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-11-04 07:28:59 -07:00
parent 6fa19bbbda
commit 52c39eefe0
2 changed files with 18 additions and 2 deletions
+5 -1
View File
@@ -173,6 +173,10 @@ type UserLoginSession struct {
Salt int64 `json:"salt,omitempty"`
}
func (u UserLoginSession) HasAuthKey() bool {
return len(u.AuthKey) == 256
}
type UserLoginMetadata struct {
Phone string `json:"phone"`
Session UserLoginSession `json:"session"`
@@ -185,7 +189,7 @@ type UserLoginMetadata struct {
}
func (s *UserLoginSession) Load(_ context.Context) (*session.Data, error) {
if len(s.AuthKey) != 256 {
if !s.HasAuthKey() {
return nil, session.ErrNotFound
}
keyID := crypto.Key(s.AuthKey).ID()