mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +00:00
fix: access tokens for service users and refresh token infos (#1779)
* fix: access token for service user * handle info from refresh request * uniqueness * postpone access token uniqueness change
This commit is contained in:
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/caos/logging"
|
||||
"github.com/jinzhu/gorm"
|
||||
@@ -80,6 +81,21 @@ func PrepareSave(table string) func(db *gorm.DB, object interface{}) error {
|
||||
}
|
||||
}
|
||||
|
||||
func PrepareSaveOnConflict(table string, conflictColumns, updateColumns []string) func(db *gorm.DB, object interface{}) error {
|
||||
updates := make([]string, len(updateColumns))
|
||||
for i, column := range updateColumns {
|
||||
updates[i] = column + "=excluded." + column
|
||||
}
|
||||
onConflict := fmt.Sprintf("ON CONFLICT (%s) DO UPDATE SET %s", strings.Join(conflictColumns, ","), strings.Join(updates, ","))
|
||||
return func(db *gorm.DB, object interface{}) error {
|
||||
err := db.Table(table).Set("gorm:insert_option", onConflict).Save(object).Error
|
||||
if err != nil {
|
||||
return caos_errs.ThrowInternal(err, "VIEW-AfC7G", "unable to put object to view")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func PrepareDeleteByKey(table string, key ColumnKey, id interface{}) func(db *gorm.DB) error {
|
||||
return func(db *gorm.DB) error {
|
||||
err := db.Table(table).
|
||||
|
Reference in New Issue
Block a user