Organize backend into product executable and shared Go modules
This commit is contained in:
1 parent
981e84a4b4
commit
f0720ec66b
382 files changed
+1944
-6989
No files matched your search
@@ -0,0 +1,24 @@
|
||||
package refreshtokens
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.sendico.io/tech/sxchnge/shared/database/repository"
|
||||
"git.sendico.io/tech/sxchnge/shared/database/repository/builder"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
func (db *RefreshTokenDB) RevokeAll(ctx context.Context, accountRef bson.ObjectID, deviceID string) error {
|
||||
query := repository.Query().
|
||||
Filter(repository.AccountField(), accountRef).
|
||||
And(repository.Query().Comparison(repository.Field("deviceId"), builder.Ne, deviceID)).
|
||||
And(repository.Query().Comparison(repository.Field(IsRevokedField), builder.Eq, false))
|
||||
|
||||
patch := repository.Patch().
|
||||
Set(repository.Field(ExpiresAtField), time.Now()).
|
||||
Set(repository.Field(IsRevokedField), true)
|
||||
|
||||
_, err := db.Repository.PatchMany(ctx, query, patch)
|
||||
return err
|
||||
}
|
||||
Reference in new issue
Block a user