tsk-34: Update last login of user (#37)

Closes #34

Reviewed-on: phoenix/textsender-auth#37
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-12-31 23:13:02 +00:00
committed by phoenix
parent d34cad033d
commit de171b790d
10 changed files with 101 additions and 12 deletions
+22
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"sync"
"time"
"git.kundeng.us/phoenix/textsender-models/tx0/user"
"github.com/google/uuid"
@@ -101,3 +102,24 @@ func (m *MockServiceUserStore) GetWithId(ctx context.Context, id uuid.UUID) (*us
return nil, nil
}
func (m *MockServiceUserStore) UpdateLastLogin(ctx context.Context, id uuid.UUID, lastLogin time.Time) (int64, error) {
m.mu.Lock()
defer m.mu.Unlock()
if m.Error != nil {
return 0, m.Error
}
serviceUser, exists := m.ServiceUsers[id]
if !exists {
return 0, errors.New("Service user not found")
}
serviceUser.LastLogin = &lastLogin
m.ServiceUsers[id] = serviceUser
m.ServiceUsersByUsername[serviceUser.Username] = serviceUser
return 1, nil
}