Skip to content

Commit ca8f821

Browse files
committed
refactor(repository): streamline LogoutUser method by removing token creation logic
1 parent 121a3e4 commit ca8f821

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

app/users/repository/logout_users.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ package repository
22

33
import (
44
"context"
5-
"github.com/hammer-code/lms-be/domain"
65
"time"
6+
7+
"github.com/hammer-code/lms-be/domain"
78
)
89

910
func (repo *repository) LogoutUser(ctx context.Context, token string, expiredAt time.Time) error {
10-
err := repo.db.DB(ctx).Create(&domain.LogoutToken{
11-
Token: token,
12-
ExpiredAt: expiredAt,
13-
CreatedAt: time.Now(),
14-
}).Error
15-
16-
if err != nil {
11+
if err := repo.db.DB(ctx).Model(&domain.LogoutToken{}).Where("token = ?", token).Update("status", 0).Error; err != nil {
1712
return err
1813
}
1914

0 commit comments

Comments
 (0)