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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user