mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 16:17:32 +00:00
feat: password age policy (#8132)
# Which Problems Are Solved Some organizations / customers have the requirement, that there users regularly need to change their password. ZITADEL already had the possibility to manage a `password age policy` ( thought the API) with the maximum amount of days a password should be valid, resp. days after with the user should be warned of the upcoming expiration. The policy could not be managed though the Console UI and was not checked in the Login UI. # How the Problems Are Solved - The policy can be managed in the Console UI's settings sections on an instance and organization level. - During an authentication in the Login UI, if a policy is set with an expiry (>0) and the user's last password change exceeds the amount of days set, the user will be prompted to change their password. - The prompt message of the Login UI can be customized in the Custom Login Texts though the Console and API on the instance and each organization. - The information when the user last changed their password is returned in the Auth, Management and User V2 API. - The policy can be retrieved in the settings service as `password expiry settings`. # Additional Changes None. # Additional Context - closes #8081 --------- Co-authored-by: Tim Möhlmann <tim+github@zitadel.com>
This commit is contained in:
@@ -891,6 +891,9 @@ func passwordChangeKeyToDomain(text *CustomText, result *domain.CustomLoginText)
|
||||
if text.Key == domain.LoginKeyPasswordChangeDescription {
|
||||
result.PasswordChange.Description = text.Text
|
||||
}
|
||||
if text.Key == domain.LoginKeyPasswordChangeExpiredDescription {
|
||||
result.PasswordChange.ExpiredDescription = text.Text
|
||||
}
|
||||
if text.Key == domain.LoginKeyPasswordChangeOldPasswordLabel {
|
||||
result.PasswordChange.OldPasswordLabel = text.Text
|
||||
}
|
||||
|
@@ -21,21 +21,21 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names3.login_name" +
|
||||
", projections.users12_humans.email" +
|
||||
", projections.users12_humans.first_name" +
|
||||
", projections.users12_humans.last_name" +
|
||||
", projections.users12_humans.display_name" +
|
||||
", projections.users12_machines.name" +
|
||||
", projections.users12_humans.avatar_key" +
|
||||
", projections.users12.type" +
|
||||
", projections.users13_humans.email" +
|
||||
", projections.users13_humans.first_name" +
|
||||
", projections.users13_humans.last_name" +
|
||||
", projections.users13_humans.display_name" +
|
||||
", projections.users13_machines.name" +
|
||||
", projections.users13_humans.avatar_key" +
|
||||
", projections.users13.type" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.instance_members4 AS members " +
|
||||
"LEFT JOIN projections.users12_humans " +
|
||||
"ON members.user_id = projections.users12_humans.user_id AND members.instance_id = projections.users12_humans.instance_id " +
|
||||
"LEFT JOIN projections.users12_machines " +
|
||||
"ON members.user_id = projections.users12_machines.user_id AND members.instance_id = projections.users12_machines.instance_id " +
|
||||
"LEFT JOIN projections.users12 " +
|
||||
"ON members.user_id = projections.users12.id AND members.instance_id = projections.users12.instance_id " +
|
||||
"LEFT JOIN projections.users13_humans " +
|
||||
"ON members.user_id = projections.users13_humans.user_id AND members.instance_id = projections.users13_humans.instance_id " +
|
||||
"LEFT JOIN projections.users13_machines " +
|
||||
"ON members.user_id = projections.users13_machines.user_id AND members.instance_id = projections.users13_machines.instance_id " +
|
||||
"LEFT JOIN projections.users13 " +
|
||||
"ON members.user_id = projections.users13.id AND members.instance_id = projections.users13.instance_id " +
|
||||
"LEFT JOIN projections.login_names3 " +
|
||||
"ON members.user_id = projections.login_names3.user_id AND members.instance_id = projections.login_names3.instance_id " +
|
||||
"AS OF SYSTEM TIME '-1 ms' " +
|
||||
|
@@ -21,24 +21,24 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names3.login_name" +
|
||||
", projections.users12_humans.email" +
|
||||
", projections.users12_humans.first_name" +
|
||||
", projections.users12_humans.last_name" +
|
||||
", projections.users12_humans.display_name" +
|
||||
", projections.users12_machines.name" +
|
||||
", projections.users12_humans.avatar_key" +
|
||||
", projections.users12.type" +
|
||||
", projections.users13_humans.email" +
|
||||
", projections.users13_humans.first_name" +
|
||||
", projections.users13_humans.last_name" +
|
||||
", projections.users13_humans.display_name" +
|
||||
", projections.users13_machines.name" +
|
||||
", projections.users13_humans.avatar_key" +
|
||||
", projections.users13.type" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.org_members4 AS members " +
|
||||
"LEFT JOIN projections.users12_humans " +
|
||||
"ON members.user_id = projections.users12_humans.user_id " +
|
||||
"AND members.instance_id = projections.users12_humans.instance_id " +
|
||||
"LEFT JOIN projections.users12_machines " +
|
||||
"ON members.user_id = projections.users12_machines.user_id " +
|
||||
"AND members.instance_id = projections.users12_machines.instance_id " +
|
||||
"LEFT JOIN projections.users12 " +
|
||||
"ON members.user_id = projections.users12.id " +
|
||||
"AND members.instance_id = projections.users12.instance_id " +
|
||||
"LEFT JOIN projections.users13_humans " +
|
||||
"ON members.user_id = projections.users13_humans.user_id " +
|
||||
"AND members.instance_id = projections.users13_humans.instance_id " +
|
||||
"LEFT JOIN projections.users13_machines " +
|
||||
"ON members.user_id = projections.users13_machines.user_id " +
|
||||
"AND members.instance_id = projections.users13_machines.instance_id " +
|
||||
"LEFT JOIN projections.users13 " +
|
||||
"ON members.user_id = projections.users13.id " +
|
||||
"AND members.instance_id = projections.users13.instance_id " +
|
||||
"LEFT JOIN projections.login_names3 " +
|
||||
"ON members.user_id = projections.login_names3.user_id " +
|
||||
"AND members.instance_id = projections.login_names3.instance_id " +
|
||||
|
@@ -21,24 +21,24 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names3.login_name" +
|
||||
", projections.users12_humans.email" +
|
||||
", projections.users12_humans.first_name" +
|
||||
", projections.users12_humans.last_name" +
|
||||
", projections.users12_humans.display_name" +
|
||||
", projections.users12_machines.name" +
|
||||
", projections.users12_humans.avatar_key" +
|
||||
", projections.users12.type" +
|
||||
", projections.users13_humans.email" +
|
||||
", projections.users13_humans.first_name" +
|
||||
", projections.users13_humans.last_name" +
|
||||
", projections.users13_humans.display_name" +
|
||||
", projections.users13_machines.name" +
|
||||
", projections.users13_humans.avatar_key" +
|
||||
", projections.users13.type" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.project_grant_members4 AS members " +
|
||||
"LEFT JOIN projections.users12_humans " +
|
||||
"ON members.user_id = projections.users12_humans.user_id " +
|
||||
"AND members.instance_id = projections.users12_humans.instance_id " +
|
||||
"LEFT JOIN projections.users12_machines " +
|
||||
"ON members.user_id = projections.users12_machines.user_id " +
|
||||
"AND members.instance_id = projections.users12_machines.instance_id " +
|
||||
"LEFT JOIN projections.users12 " +
|
||||
"ON members.user_id = projections.users12.id " +
|
||||
"AND members.instance_id = projections.users12.instance_id " +
|
||||
"LEFT JOIN projections.users13_humans " +
|
||||
"ON members.user_id = projections.users13_humans.user_id " +
|
||||
"AND members.instance_id = projections.users13_humans.instance_id " +
|
||||
"LEFT JOIN projections.users13_machines " +
|
||||
"ON members.user_id = projections.users13_machines.user_id " +
|
||||
"AND members.instance_id = projections.users13_machines.instance_id " +
|
||||
"LEFT JOIN projections.users13 " +
|
||||
"ON members.user_id = projections.users13.id " +
|
||||
"AND members.instance_id = projections.users13.instance_id " +
|
||||
"LEFT JOIN projections.login_names3 " +
|
||||
"ON members.user_id = projections.login_names3.user_id " +
|
||||
"AND members.instance_id = projections.login_names3.instance_id " +
|
||||
|
@@ -21,24 +21,24 @@ var (
|
||||
", members.user_id" +
|
||||
", members.roles" +
|
||||
", projections.login_names3.login_name" +
|
||||
", projections.users12_humans.email" +
|
||||
", projections.users12_humans.first_name" +
|
||||
", projections.users12_humans.last_name" +
|
||||
", projections.users12_humans.display_name" +
|
||||
", projections.users12_machines.name" +
|
||||
", projections.users12_humans.avatar_key" +
|
||||
", projections.users12.type" +
|
||||
", projections.users13_humans.email" +
|
||||
", projections.users13_humans.first_name" +
|
||||
", projections.users13_humans.last_name" +
|
||||
", projections.users13_humans.display_name" +
|
||||
", projections.users13_machines.name" +
|
||||
", projections.users13_humans.avatar_key" +
|
||||
", projections.users13.type" +
|
||||
", COUNT(*) OVER () " +
|
||||
"FROM projections.project_members4 AS members " +
|
||||
"LEFT JOIN projections.users12_humans " +
|
||||
"ON members.user_id = projections.users12_humans.user_id " +
|
||||
"AND members.instance_id = projections.users12_humans.instance_id " +
|
||||
"LEFT JOIN projections.users12_machines " +
|
||||
"ON members.user_id = projections.users12_machines.user_id " +
|
||||
"AND members.instance_id = projections.users12_machines.instance_id " +
|
||||
"LEFT JOIN projections.users12 " +
|
||||
"ON members.user_id = projections.users12.id " +
|
||||
"AND members.instance_id = projections.users12.instance_id " +
|
||||
"LEFT JOIN projections.users13_humans " +
|
||||
"ON members.user_id = projections.users13_humans.user_id " +
|
||||
"AND members.instance_id = projections.users13_humans.instance_id " +
|
||||
"LEFT JOIN projections.users13_machines " +
|
||||
"ON members.user_id = projections.users13_machines.user_id " +
|
||||
"AND members.instance_id = projections.users13_machines.instance_id " +
|
||||
"LEFT JOIN projections.users13 " +
|
||||
"ON members.user_id = projections.users13.id " +
|
||||
"AND members.instance_id = projections.users13.instance_id " +
|
||||
"LEFT JOIN projections.login_names3 " +
|
||||
"ON members.user_id = projections.login_names3.user_id " +
|
||||
"AND members.instance_id = projections.login_names3.instance_id " +
|
||||
|
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UserTable = "projections.users12"
|
||||
UserTable = "projections.users13"
|
||||
UserHumanTable = UserTable + "_" + UserHumanSuffix
|
||||
UserMachineTable = UserTable + "_" + UserMachineSuffix
|
||||
UserNotifyTable = UserTable + "_" + UserNotifySuffix
|
||||
@@ -35,6 +35,7 @@ const (
|
||||
HumanUserIDCol = "user_id"
|
||||
HumanUserInstanceIDCol = "instance_id"
|
||||
HumanPasswordChangeRequired = "password_change_required"
|
||||
HumanPasswordChanged = "password_changed"
|
||||
|
||||
// profile
|
||||
HumanFirstNameCol = "first_name"
|
||||
@@ -116,6 +117,7 @@ func (*userProjection) Init() *old_handler.Check {
|
||||
handler.NewColumn(HumanPhoneCol, handler.ColumnTypeText, handler.Nullable()),
|
||||
handler.NewColumn(HumanIsPhoneVerifiedCol, handler.ColumnTypeBool, handler.Nullable()),
|
||||
handler.NewColumn(HumanPasswordChangeRequired, handler.ColumnTypeBool),
|
||||
handler.NewColumn(HumanPasswordChanged, handler.ColumnTypeTimestamp, handler.Nullable()),
|
||||
},
|
||||
handler.NewPrimaryKey(HumanUserInstanceIDCol, HumanUserIDCol),
|
||||
UserHumanSuffix,
|
||||
@@ -322,6 +324,7 @@ func (p *userProjection) reduceHumanAdded(event eventstore.Event) (*handler.Stat
|
||||
if !ok {
|
||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-Ebynp", "reduce.wrong.event.type %s", user.HumanAddedType)
|
||||
}
|
||||
passwordSet := crypto.SecretOrEncodedHash(e.Secret, e.EncodedHash) != ""
|
||||
return handler.NewMultiStatement(
|
||||
e,
|
||||
handler.AddCreateStatement(
|
||||
@@ -350,6 +353,7 @@ func (p *userProjection) reduceHumanAdded(event eventstore.Event) (*handler.Stat
|
||||
handler.NewCol(HumanEmailCol, e.EmailAddress),
|
||||
handler.NewCol(HumanPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
||||
handler.NewCol(HumanPasswordChangeRequired, e.ChangeRequired),
|
||||
handler.NewCol(HumanPasswordChanged, &sql.NullTime{Time: e.CreatedAt(), Valid: passwordSet}),
|
||||
},
|
||||
handler.WithTableSuffix(UserHumanSuffix),
|
||||
),
|
||||
@@ -359,7 +363,7 @@ func (p *userProjection) reduceHumanAdded(event eventstore.Event) (*handler.Stat
|
||||
handler.NewCol(NotifyInstanceIDCol, e.Aggregate().InstanceID),
|
||||
handler.NewCol(NotifyLastEmailCol, e.EmailAddress),
|
||||
handler.NewCol(NotifyLastPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
||||
handler.NewCol(NotifyPasswordSetCol, crypto.SecretOrEncodedHash(e.Secret, e.EncodedHash) != ""),
|
||||
handler.NewCol(NotifyPasswordSetCol, passwordSet),
|
||||
},
|
||||
handler.WithTableSuffix(UserNotifySuffix),
|
||||
),
|
||||
@@ -371,6 +375,7 @@ func (p *userProjection) reduceHumanRegistered(event eventstore.Event) (*handler
|
||||
if !ok {
|
||||
return nil, zerrors.ThrowInvalidArgumentf(nil, "HANDL-xE53M", "reduce.wrong.event.type %s", user.HumanRegisteredType)
|
||||
}
|
||||
passwordSet := crypto.SecretOrEncodedHash(e.Secret, e.EncodedHash) != ""
|
||||
return handler.NewMultiStatement(
|
||||
e,
|
||||
handler.AddCreateStatement(
|
||||
@@ -399,6 +404,7 @@ func (p *userProjection) reduceHumanRegistered(event eventstore.Event) (*handler
|
||||
handler.NewCol(HumanEmailCol, e.EmailAddress),
|
||||
handler.NewCol(HumanPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
||||
handler.NewCol(HumanPasswordChangeRequired, e.ChangeRequired),
|
||||
handler.NewCol(HumanPasswordChanged, &sql.NullTime{Time: e.CreatedAt(), Valid: passwordSet}),
|
||||
},
|
||||
handler.WithTableSuffix(UserHumanSuffix),
|
||||
),
|
||||
@@ -408,7 +414,7 @@ func (p *userProjection) reduceHumanRegistered(event eventstore.Event) (*handler
|
||||
handler.NewCol(NotifyInstanceIDCol, e.Aggregate().InstanceID),
|
||||
handler.NewCol(NotifyLastEmailCol, e.EmailAddress),
|
||||
handler.NewCol(NotifyLastPhoneCol, &sql.NullString{String: string(e.PhoneNumber), Valid: e.PhoneNumber != ""}),
|
||||
handler.NewCol(NotifyPasswordSetCol, crypto.SecretOrEncodedHash(e.Secret, e.EncodedHash) != ""),
|
||||
handler.NewCol(NotifyPasswordSetCol, passwordSet),
|
||||
},
|
||||
handler.WithTableSuffix(UserNotifySuffix),
|
||||
),
|
||||
@@ -918,6 +924,7 @@ func (p *userProjection) reduceHumanPasswordChanged(event eventstore.Event) (*ha
|
||||
handler.AddUpdateStatement(
|
||||
[]handler.Column{
|
||||
handler.NewCol(HumanPasswordChangeRequired, e.ChangeRequired),
|
||||
handler.NewCol(HumanPasswordChanged, &sql.NullTime{Time: e.CreatedAt(), Valid: true}),
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(HumanUserIDCol, e.Aggregate().ID),
|
||||
|
@@ -3,6 +3,7 @@ package projection
|
||||
import (
|
||||
"database/sql"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
@@ -14,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestUserProjection_reduces(t *testing.T) {
|
||||
testNow := time.Now()
|
||||
type args struct {
|
||||
event func(t *testing.T) eventstore.Event
|
||||
}
|
||||
@@ -27,7 +29,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceHumanAdded",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.HumanAddedType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
@@ -42,6 +44,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
"phone": "+41 00 000 00 00",
|
||||
"changeRequired": true
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanAddedEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanAdded,
|
||||
@@ -51,7 +54,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -65,7 +68,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.users13_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required, password_changed) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -78,10 +81,11 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
true,
|
||||
&sql.NullTime{Time: testNow, Valid: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -98,7 +102,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceUserV1Added",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.UserV1AddedType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
@@ -112,6 +116,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
"email": "email@zitadel.com",
|
||||
"phone": "+41 00 000 00 00"
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanAddedEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanAdded,
|
||||
@@ -121,7 +126,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -135,7 +140,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.users13_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required, password_changed) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -148,10 +153,11 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
false,
|
||||
&sql.NullTime{Time: testNow, Valid: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -168,7 +174,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceHumanAdded NULLs",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.HumanAddedType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
@@ -177,6 +183,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
"lastName": "last-name",
|
||||
"email": "email@zitadel.com"
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanAddedEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanAdded,
|
||||
@@ -186,7 +193,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -200,7 +207,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.users13_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required, password_changed) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -213,10 +220,11 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
&sql.NullString{},
|
||||
false,
|
||||
&sql.NullTime{Time: testNow, Valid: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -233,7 +241,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceHumanRegistered",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.HumanRegisteredType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
@@ -248,6 +256,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
"phone": "+41 00 000 00 00",
|
||||
"changeRequired": true
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanRegisteredEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanRegistered,
|
||||
@@ -257,7 +266,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -271,7 +280,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.users13_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required, password_changed) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -284,10 +293,11 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
true,
|
||||
&sql.NullTime{Time: testNow, Valid: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -304,7 +314,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceUserV1Registered",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.UserV1RegisteredType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
@@ -318,6 +328,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
"email": "email@zitadel.com",
|
||||
"phone": "+41 00 000 00 00"
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanRegisteredEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanRegistered,
|
||||
@@ -327,7 +338,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -341,7 +352,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.users13_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required, password_changed) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -354,10 +365,11 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
false,
|
||||
&sql.NullTime{Time: testNow, Valid: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -374,7 +386,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceHumanRegistered NULLs",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.HumanRegisteredType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
@@ -383,6 +395,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
"lastName": "last-name",
|
||||
"email": "email@zitadel.com"
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanRegisteredEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanRegistered,
|
||||
@@ -392,7 +405,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -406,7 +419,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
expectedStmt: "INSERT INTO projections.users13_humans (user_id, instance_id, first_name, last_name, nick_name, display_name, preferred_language, gender, email, phone, password_change_required, password_changed) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -419,10 +432,11 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
&sql.NullString{},
|
||||
false,
|
||||
&sql.NullTime{Time: testNow, Valid: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_notifications (user_id, instance_id, last_email, last_phone, password_set) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -452,7 +466,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateInitial,
|
||||
"agg-id",
|
||||
@@ -480,7 +494,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateInitial,
|
||||
"agg-id",
|
||||
@@ -508,7 +522,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateActive,
|
||||
"agg-id",
|
||||
@@ -536,7 +550,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13 SET state = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateActive,
|
||||
"agg-id",
|
||||
@@ -564,7 +578,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateLocked,
|
||||
@@ -594,7 +608,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateActive,
|
||||
@@ -624,7 +638,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateInactive,
|
||||
@@ -654,7 +668,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserStateActive,
|
||||
@@ -684,7 +698,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.users12 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.users13 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -713,7 +727,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"username",
|
||||
@@ -745,7 +759,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, username, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"id@temporary.domain",
|
||||
@@ -782,7 +796,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -791,7 +805,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"first-name",
|
||||
"last-name",
|
||||
@@ -831,7 +845,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -840,7 +854,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (first_name, last_name, nick_name, display_name, preferred_language, gender) = ($1, $2, $3, $4, $5, $6) WHERE (user_id = $7) AND (instance_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"first-name",
|
||||
"last-name",
|
||||
@@ -875,7 +889,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -884,7 +898,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.PhoneNumber("+41 00 000 00 00"),
|
||||
false,
|
||||
@@ -893,7 +907,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
"agg-id",
|
||||
@@ -923,7 +937,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -932,7 +946,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.PhoneNumber("+41 00 000 00 00"),
|
||||
false,
|
||||
@@ -941,7 +955,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET last_phone = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "+41 00 000 00 00", Valid: true},
|
||||
"agg-id",
|
||||
@@ -969,7 +983,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -978,7 +992,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -987,7 +1001,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -1016,7 +1030,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1025,7 +1039,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (phone, is_phone_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -1034,7 +1048,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET (last_phone, verified_phone) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
nil,
|
||||
@@ -1063,7 +1077,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1072,7 +1086,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1080,7 +1094,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1107,7 +1121,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1116,7 +1130,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET is_phone_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1124,7 +1138,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET verified_phone = last_phone WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1153,7 +1167,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1162,7 +1176,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
false,
|
||||
@@ -1171,7 +1185,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "email@zitadel.com", Valid: true},
|
||||
"agg-id",
|
||||
@@ -1201,7 +1215,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1210,7 +1224,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (email, is_email_verified) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.EmailAddress("email@zitadel.com"),
|
||||
false,
|
||||
@@ -1219,7 +1233,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET last_email = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
&sql.NullString{String: "email@zitadel.com", Valid: true},
|
||||
"agg-id",
|
||||
@@ -1247,7 +1261,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1256,7 +1270,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1264,7 +1278,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1291,7 +1305,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1300,7 +1314,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET is_email_verified = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1308,7 +1322,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET verified_email = last_email WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1337,7 +1351,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1346,7 +1360,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"users/agg-id/avatar",
|
||||
"agg-id",
|
||||
@@ -1374,7 +1388,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1383,7 +1397,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET avatar_key = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
"agg-id",
|
||||
@@ -1398,12 +1412,13 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceHumanPasswordChanged",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.HumanPasswordChangedType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
"changeRequired": true
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanPasswordChangedEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanPasswordChanged,
|
||||
@@ -1413,15 +1428,16 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET password_change_required = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (password_change_required, password_changed) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
&sql.NullTime{Time: testNow, Valid: true},
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET password_set = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET password_set = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1436,12 +1452,13 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
name: "reduceHumanPasswordChanged, false",
|
||||
args: args{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
timedTestEvent(
|
||||
user.HumanPasswordChangedType,
|
||||
user.AggregateType,
|
||||
[]byte(`{
|
||||
"changeRequired": false
|
||||
}`),
|
||||
testNow,
|
||||
), user.HumanPasswordChangedEventMapper),
|
||||
},
|
||||
reduce: (&userProjection{}).reduceHumanPasswordChanged,
|
||||
@@ -1451,15 +1468,16 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_humans SET password_change_required = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_humans SET (password_change_required, password_changed) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
false,
|
||||
&sql.NullTime{Time: testNow, Valid: true},
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_notifications SET password_set = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_notifications SET password_set = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"agg-id",
|
||||
@@ -1490,7 +1508,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -1504,7 +1522,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1538,7 +1556,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedStmt: "INSERT INTO projections.users13 (id, creation_date, change_date, resource_owner, instance_id, state, sequence, username, type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
anyArg{},
|
||||
@@ -1552,7 +1570,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "INSERT INTO projections.users12_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedStmt: "INSERT INTO projections.users13_machines (user_id, instance_id, name, description, access_token_type) VALUES ($1, $2, $3, $4, $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
@@ -1585,7 +1603,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1594,7 +1612,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_machines SET (name, description) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13_machines SET (name, description) = ($1, $2) WHERE (user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"machine-name",
|
||||
"description",
|
||||
@@ -1625,7 +1643,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1634,7 +1652,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_machines SET name = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_machines SET name = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"machine-name",
|
||||
"agg-id",
|
||||
@@ -1664,7 +1682,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1673,7 +1691,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_machines SET description = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_machines SET description = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"description",
|
||||
"agg-id",
|
||||
@@ -1722,7 +1740,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1731,7 +1749,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"secret",
|
||||
"agg-id",
|
||||
@@ -1761,7 +1779,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1770,7 +1788,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"secret",
|
||||
"agg-id",
|
||||
@@ -1800,7 +1818,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1809,7 +1827,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"secret",
|
||||
"agg-id",
|
||||
@@ -1837,7 +1855,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedStmt: "UPDATE projections.users13 SET (change_date, sequence) = ($1, $2) WHERE (id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@@ -1846,7 +1864,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.users12_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedStmt: "UPDATE projections.users13_machines SET secret = $1 WHERE (user_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
nil,
|
||||
"agg-id",
|
||||
@@ -1874,7 +1892,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.users12 WHERE (instance_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.users13 WHERE (instance_id = $1) AND (resource_owner = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
@@ -1901,7 +1919,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.users12 WHERE (instance_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.users13 WHERE (instance_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
@@ -31,7 +31,7 @@ var (
|
||||
` projections.sessions8.user_resource_owner,` +
|
||||
` projections.sessions8.user_checked_at,` +
|
||||
` projections.login_names3.login_name,` +
|
||||
` projections.users12_humans.display_name,` +
|
||||
` projections.users13_humans.display_name,` +
|
||||
` projections.sessions8.password_checked_at,` +
|
||||
` projections.sessions8.intent_checked_at,` +
|
||||
` projections.sessions8.webauthn_checked_at,` +
|
||||
@@ -48,8 +48,8 @@ var (
|
||||
` projections.sessions8.expiration` +
|
||||
` FROM projections.sessions8` +
|
||||
` LEFT JOIN projections.login_names3 ON projections.sessions8.user_id = projections.login_names3.user_id AND projections.sessions8.instance_id = projections.login_names3.instance_id` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.sessions8.user_id = projections.users12_humans.user_id AND projections.sessions8.instance_id = projections.users12_humans.instance_id` +
|
||||
` LEFT JOIN projections.users12 ON projections.sessions8.user_id = projections.users12.id AND projections.sessions8.instance_id = projections.users12.instance_id` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.sessions8.user_id = projections.users13_humans.user_id AND projections.sessions8.instance_id = projections.users13_humans.instance_id` +
|
||||
` LEFT JOIN projections.users13 ON projections.sessions8.user_id = projections.users13.id AND projections.sessions8.instance_id = projections.users13.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`)
|
||||
expectedSessionsQuery = regexp.QuoteMeta(`SELECT projections.sessions8.id,` +
|
||||
` projections.sessions8.creation_date,` +
|
||||
@@ -62,7 +62,7 @@ var (
|
||||
` projections.sessions8.user_resource_owner,` +
|
||||
` projections.sessions8.user_checked_at,` +
|
||||
` projections.login_names3.login_name,` +
|
||||
` projections.users12_humans.display_name,` +
|
||||
` projections.users13_humans.display_name,` +
|
||||
` projections.sessions8.password_checked_at,` +
|
||||
` projections.sessions8.intent_checked_at,` +
|
||||
` projections.sessions8.webauthn_checked_at,` +
|
||||
@@ -75,8 +75,8 @@ var (
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.sessions8` +
|
||||
` LEFT JOIN projections.login_names3 ON projections.sessions8.user_id = projections.login_names3.user_id AND projections.sessions8.instance_id = projections.login_names3.instance_id` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.sessions8.user_id = projections.users12_humans.user_id AND projections.sessions8.instance_id = projections.users12_humans.instance_id` +
|
||||
` LEFT JOIN projections.users12 ON projections.sessions8.user_id = projections.users12.id AND projections.sessions8.instance_id = projections.users12.instance_id` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.sessions8.user_id = projections.users13_humans.user_id AND projections.sessions8.instance_id = projections.users13_humans.instance_id` +
|
||||
` LEFT JOIN projections.users13 ON projections.sessions8.user_id = projections.users13.id AND projections.sessions8.instance_id = projections.users13.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`)
|
||||
|
||||
sessionCols = []string{
|
||||
|
@@ -53,6 +53,7 @@ type Human struct {
|
||||
Phone domain.PhoneNumber `json:"phone,omitempty"`
|
||||
IsPhoneVerified bool `json:"is_phone_verified,omitempty"`
|
||||
PasswordChangeRequired bool `json:"password_change_required,omitempty"`
|
||||
PasswordChanged time.Time `json:"password_changed,omitempty"`
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
@@ -280,6 +281,10 @@ var (
|
||||
name: projection.HumanPasswordChangeRequired,
|
||||
table: humanTable,
|
||||
}
|
||||
HumanPasswordChangedCol = Column{
|
||||
name: projection.HumanPasswordChanged,
|
||||
table: humanTable,
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -822,6 +827,7 @@ func scanUser(row *sql.Row) (*User, error) {
|
||||
phone := sql.NullString{}
|
||||
isPhoneVerified := sql.NullBool{}
|
||||
passwordChangeRequired := sql.NullBool{}
|
||||
passwordChanged := sql.NullTime{}
|
||||
|
||||
machineID := sql.NullString{}
|
||||
name := sql.NullString{}
|
||||
@@ -853,6 +859,7 @@ func scanUser(row *sql.Row) (*User, error) {
|
||||
&phone,
|
||||
&isPhoneVerified,
|
||||
&passwordChangeRequired,
|
||||
&passwordChanged,
|
||||
&machineID,
|
||||
&name,
|
||||
&description,
|
||||
@@ -884,6 +891,7 @@ func scanUser(row *sql.Row) (*User, error) {
|
||||
Phone: domain.PhoneNumber(phone.String),
|
||||
IsPhoneVerified: isPhoneVerified.Bool,
|
||||
PasswordChangeRequired: passwordChangeRequired.Bool,
|
||||
PasswordChanged: passwordChanged.Time,
|
||||
}
|
||||
} else if machineID.Valid {
|
||||
u.Machine = &Machine{
|
||||
@@ -929,6 +937,7 @@ func prepareUserQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilder
|
||||
HumanPhoneCol.identifier(),
|
||||
HumanIsPhoneVerifiedCol.identifier(),
|
||||
HumanPasswordChangeRequiredCol.identifier(),
|
||||
HumanPasswordChangedCol.identifier(),
|
||||
MachineUserIDCol.identifier(),
|
||||
MachineNameCol.identifier(),
|
||||
MachineDescriptionCol.identifier(),
|
||||
@@ -1316,6 +1325,7 @@ func prepareUsersQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilde
|
||||
HumanPhoneCol.identifier(),
|
||||
HumanIsPhoneVerifiedCol.identifier(),
|
||||
HumanPasswordChangeRequiredCol.identifier(),
|
||||
HumanPasswordChangedCol.identifier(),
|
||||
MachineUserIDCol.identifier(),
|
||||
MachineNameCol.identifier(),
|
||||
MachineDescriptionCol.identifier(),
|
||||
@@ -1355,6 +1365,7 @@ func prepareUsersQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilde
|
||||
phone := sql.NullString{}
|
||||
isPhoneVerified := sql.NullBool{}
|
||||
passwordChangeRequired := sql.NullBool{}
|
||||
passwordChanged := sql.NullTime{}
|
||||
|
||||
machineID := sql.NullString{}
|
||||
name := sql.NullString{}
|
||||
@@ -1386,6 +1397,7 @@ func prepareUsersQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilde
|
||||
&phone,
|
||||
&isPhoneVerified,
|
||||
&passwordChangeRequired,
|
||||
&passwordChanged,
|
||||
&machineID,
|
||||
&name,
|
||||
&description,
|
||||
@@ -1416,6 +1428,7 @@ func prepareUsersQuery(ctx context.Context, db prepareDatabase) (sq.SelectBuilde
|
||||
Phone: domain.PhoneNumber(phone.String),
|
||||
IsPhoneVerified: isPhoneVerified.Bool,
|
||||
PasswordChangeRequired: passwordChangeRequired.Bool,
|
||||
PasswordChanged: passwordChanged.Time,
|
||||
}
|
||||
} else if machineID.Valid {
|
||||
u.Machine = &Machine{
|
||||
|
@@ -40,29 +40,29 @@ var (
|
||||
"method_type",
|
||||
"count",
|
||||
}
|
||||
prepareActiveAuthMethodTypesStmt = `SELECT projections.users12_notifications.password_set,` +
|
||||
prepareActiveAuthMethodTypesStmt = `SELECT projections.users13_notifications.password_set,` +
|
||||
` auth_method_types.method_type,` +
|
||||
` user_idps_count.count` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_notifications ON projections.users12.id = projections.users12_notifications.user_id AND projections.users12.instance_id = projections.users12_notifications.instance_id` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_notifications ON projections.users13.id = projections.users13_notifications.user_id AND projections.users13.instance_id = projections.users13_notifications.instance_id` +
|
||||
` LEFT JOIN (SELECT DISTINCT(auth_method_types.method_type), auth_method_types.user_id, auth_method_types.instance_id FROM projections.user_auth_methods4 AS auth_method_types` +
|
||||
` WHERE auth_method_types.state = $1) AS auth_method_types` +
|
||||
` ON auth_method_types.user_id = projections.users12.id AND auth_method_types.instance_id = projections.users12.instance_id` +
|
||||
` ON auth_method_types.user_id = projections.users13.id AND auth_method_types.instance_id = projections.users13.instance_id` +
|
||||
` LEFT JOIN (SELECT user_idps_count.user_id, user_idps_count.instance_id, COUNT(user_idps_count.user_id) AS count FROM projections.idp_user_links3 AS user_idps_count` +
|
||||
` GROUP BY user_idps_count.user_id, user_idps_count.instance_id) AS user_idps_count` +
|
||||
` ON user_idps_count.user_id = projections.users12.id AND user_idps_count.instance_id = projections.users12.instance_id` +
|
||||
` ON user_idps_count.user_id = projections.users13.id AND user_idps_count.instance_id = projections.users13.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms`
|
||||
prepareActiveAuthMethodTypesCols = []string{
|
||||
"password_set",
|
||||
"method_type",
|
||||
"idps_count",
|
||||
}
|
||||
prepareAuthMethodTypesRequiredStmt = `SELECT projections.users12.type,` +
|
||||
prepareAuthMethodTypesRequiredStmt = `SELECT projections.users13.type,` +
|
||||
` auth_methods_force_mfa.force_mfa,` +
|
||||
` auth_methods_force_mfa.force_mfa_local_only` +
|
||||
` FROM projections.users12` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN (SELECT auth_methods_force_mfa.force_mfa, auth_methods_force_mfa.force_mfa_local_only, auth_methods_force_mfa.instance_id, auth_methods_force_mfa.aggregate_id, auth_methods_force_mfa.is_default FROM projections.login_policies5 AS auth_methods_force_mfa) AS auth_methods_force_mfa` +
|
||||
` ON (auth_methods_force_mfa.aggregate_id = projections.users12.instance_id OR auth_methods_force_mfa.aggregate_id = projections.users12.resource_owner) AND auth_methods_force_mfa.instance_id = projections.users12.instance_id` +
|
||||
` ON (auth_methods_force_mfa.aggregate_id = projections.users13.instance_id OR auth_methods_force_mfa.aggregate_id = projections.users13.resource_owner) AND auth_methods_force_mfa.instance_id = projections.users13.instance_id` +
|
||||
` ORDER BY auth_methods_force_mfa.is_default LIMIT 1
|
||||
`
|
||||
prepareAuthMethodTypesRequiredCols = []string{
|
||||
|
@@ -59,20 +59,21 @@ SELECT
|
||||
, h.phone
|
||||
, h.is_phone_verified
|
||||
, h.password_change_required
|
||||
, h.password_changed
|
||||
, m.user_id
|
||||
, m.name
|
||||
, m.description
|
||||
, m.secret
|
||||
, m.access_token_type
|
||||
, count(*) OVER ()
|
||||
FROM projections.users12 u
|
||||
FROM projections.users13 u
|
||||
LEFT JOIN
|
||||
projections.users12_humans h
|
||||
projections.users13_humans h
|
||||
ON
|
||||
u.id = h.user_id
|
||||
AND u.instance_id = h.instance_id
|
||||
LEFT JOIN
|
||||
projections.users12_machines m
|
||||
projections.users13_machines m
|
||||
ON
|
||||
u.id = m.user_id
|
||||
AND u.instance_id = m.instance_id
|
||||
|
@@ -74,6 +74,7 @@ SELECT
|
||||
, h.phone
|
||||
, h.is_phone_verified
|
||||
, h.password_change_required
|
||||
, h.password_changed
|
||||
, m.user_id
|
||||
, m.name
|
||||
, m.description
|
||||
@@ -82,17 +83,17 @@ SELECT
|
||||
, count(*) OVER ()
|
||||
FROM found_users fu
|
||||
JOIN
|
||||
projections.users12 u
|
||||
projections.users13 u
|
||||
ON
|
||||
fu.id = u.id
|
||||
AND fu.instance_id = u.instance_id
|
||||
LEFT JOIN
|
||||
projections.users12_humans h
|
||||
projections.users13_humans h
|
||||
ON
|
||||
fu.id = h.user_id
|
||||
AND fu.instance_id = h.instance_id
|
||||
LEFT JOIN
|
||||
projections.users12_machines m
|
||||
projections.users13_machines m
|
||||
ON
|
||||
fu.id = m.user_id
|
||||
AND fu.instance_id = m.instance_id
|
||||
|
@@ -23,14 +23,14 @@ var (
|
||||
", projections.user_grants5.roles" +
|
||||
", projections.user_grants5.state" +
|
||||
", projections.user_grants5.user_id" +
|
||||
", projections.users12.username" +
|
||||
", projections.users12.type" +
|
||||
", projections.users12.resource_owner" +
|
||||
", projections.users12_humans.first_name" +
|
||||
", projections.users12_humans.last_name" +
|
||||
", projections.users12_humans.email" +
|
||||
", projections.users12_humans.display_name" +
|
||||
", projections.users12_humans.avatar_key" +
|
||||
", projections.users13.username" +
|
||||
", projections.users13.type" +
|
||||
", projections.users13.resource_owner" +
|
||||
", projections.users13_humans.first_name" +
|
||||
", projections.users13_humans.last_name" +
|
||||
", projections.users13_humans.email" +
|
||||
", projections.users13_humans.display_name" +
|
||||
", projections.users13_humans.avatar_key" +
|
||||
", projections.login_names3.login_name" +
|
||||
", projections.user_grants5.resource_owner" +
|
||||
", projections.orgs1.name" +
|
||||
@@ -41,11 +41,11 @@ var (
|
||||
", granted_orgs.name" +
|
||||
", granted_orgs.primary_domain" +
|
||||
" FROM projections.user_grants5" +
|
||||
" LEFT JOIN projections.users12 ON projections.user_grants5.user_id = projections.users12.id AND projections.user_grants5.instance_id = projections.users12.instance_id" +
|
||||
" LEFT JOIN projections.users12_humans ON projections.user_grants5.user_id = projections.users12_humans.user_id AND projections.user_grants5.instance_id = projections.users12_humans.instance_id" +
|
||||
" LEFT JOIN projections.users13 ON projections.user_grants5.user_id = projections.users13.id AND projections.user_grants5.instance_id = projections.users13.instance_id" +
|
||||
" LEFT JOIN projections.users13_humans ON projections.user_grants5.user_id = projections.users13_humans.user_id AND projections.user_grants5.instance_id = projections.users13_humans.instance_id" +
|
||||
" LEFT JOIN projections.orgs1 ON projections.user_grants5.resource_owner = projections.orgs1.id AND projections.user_grants5.instance_id = projections.orgs1.instance_id" +
|
||||
" LEFT JOIN projections.projects4 ON projections.user_grants5.project_id = projections.projects4.id AND projections.user_grants5.instance_id = projections.projects4.instance_id" +
|
||||
" LEFT JOIN projections.orgs1 AS granted_orgs ON projections.users12.resource_owner = granted_orgs.id AND projections.users12.instance_id = granted_orgs.instance_id" +
|
||||
" LEFT JOIN projections.orgs1 AS granted_orgs ON projections.users13.resource_owner = granted_orgs.id AND projections.users13.instance_id = granted_orgs.instance_id" +
|
||||
" LEFT JOIN projections.login_names3 ON projections.user_grants5.user_id = projections.login_names3.user_id AND projections.user_grants5.instance_id = projections.login_names3.instance_id" +
|
||||
` AS OF SYSTEM TIME '-1 ms' ` +
|
||||
" WHERE projections.login_names3.is_primary = $1")
|
||||
@@ -85,14 +85,14 @@ var (
|
||||
", projections.user_grants5.roles" +
|
||||
", projections.user_grants5.state" +
|
||||
", projections.user_grants5.user_id" +
|
||||
", projections.users12.username" +
|
||||
", projections.users12.type" +
|
||||
", projections.users12.resource_owner" +
|
||||
", projections.users12_humans.first_name" +
|
||||
", projections.users12_humans.last_name" +
|
||||
", projections.users12_humans.email" +
|
||||
", projections.users12_humans.display_name" +
|
||||
", projections.users12_humans.avatar_key" +
|
||||
", projections.users13.username" +
|
||||
", projections.users13.type" +
|
||||
", projections.users13.resource_owner" +
|
||||
", projections.users13_humans.first_name" +
|
||||
", projections.users13_humans.last_name" +
|
||||
", projections.users13_humans.email" +
|
||||
", projections.users13_humans.display_name" +
|
||||
", projections.users13_humans.avatar_key" +
|
||||
", projections.login_names3.login_name" +
|
||||
", projections.user_grants5.resource_owner" +
|
||||
", projections.orgs1.name" +
|
||||
@@ -104,11 +104,11 @@ var (
|
||||
", granted_orgs.primary_domain" +
|
||||
", COUNT(*) OVER ()" +
|
||||
" FROM projections.user_grants5" +
|
||||
" LEFT JOIN projections.users12 ON projections.user_grants5.user_id = projections.users12.id AND projections.user_grants5.instance_id = projections.users12.instance_id" +
|
||||
" LEFT JOIN projections.users12_humans ON projections.user_grants5.user_id = projections.users12_humans.user_id AND projections.user_grants5.instance_id = projections.users12_humans.instance_id" +
|
||||
" LEFT JOIN projections.users13 ON projections.user_grants5.user_id = projections.users13.id AND projections.user_grants5.instance_id = projections.users13.instance_id" +
|
||||
" LEFT JOIN projections.users13_humans ON projections.user_grants5.user_id = projections.users13_humans.user_id AND projections.user_grants5.instance_id = projections.users13_humans.instance_id" +
|
||||
" LEFT JOIN projections.orgs1 ON projections.user_grants5.resource_owner = projections.orgs1.id AND projections.user_grants5.instance_id = projections.orgs1.instance_id" +
|
||||
" LEFT JOIN projections.projects4 ON projections.user_grants5.project_id = projections.projects4.id AND projections.user_grants5.instance_id = projections.projects4.instance_id" +
|
||||
" LEFT JOIN projections.orgs1 AS granted_orgs ON projections.users12.resource_owner = granted_orgs.id AND projections.users12.instance_id = granted_orgs.instance_id" +
|
||||
" LEFT JOIN projections.orgs1 AS granted_orgs ON projections.users13.resource_owner = granted_orgs.id AND projections.users13.instance_id = granted_orgs.instance_id" +
|
||||
" LEFT JOIN projections.login_names3 ON projections.user_grants5.user_id = projections.login_names3.user_id AND projections.user_grants5.instance_id = projections.login_names3.instance_id" +
|
||||
` AS OF SYSTEM TIME '-1 ms' ` +
|
||||
" WHERE projections.login_names3.is_primary = $1")
|
||||
|
@@ -62,14 +62,14 @@ SELECT
|
||||
, n.verified_phone
|
||||
, n.password_set
|
||||
, count(*) OVER ()
|
||||
FROM projections.users12 u
|
||||
FROM projections.users13 u
|
||||
LEFT JOIN
|
||||
projections.users12_humans h
|
||||
projections.users13_humans h
|
||||
ON
|
||||
u.id = h.user_id
|
||||
AND u.instance_id = h.instance_id
|
||||
LEFT JOIN
|
||||
projections.users12_notifications n
|
||||
projections.users13_notifications n
|
||||
ON
|
||||
u.id = n.user_id
|
||||
AND u.instance_id = n.instance_id
|
||||
|
@@ -78,17 +78,17 @@ SELECT
|
||||
, count(*) OVER ()
|
||||
FROM found_users fu
|
||||
JOIN
|
||||
projections.users12 u
|
||||
projections.users13 u
|
||||
ON
|
||||
fu.id = u.id
|
||||
AND fu.instance_id = u.instance_id
|
||||
LEFT JOIN
|
||||
projections.users12_humans h
|
||||
projections.users13_humans h
|
||||
ON
|
||||
fu.id = h.user_id
|
||||
AND fu.instance_id = h.instance_id
|
||||
LEFT JOIN
|
||||
projections.users12_notifications n
|
||||
projections.users13_notifications n
|
||||
ON
|
||||
fu.id = n.user_id
|
||||
AND fu.instance_id = n.instance_id
|
||||
|
@@ -147,44 +147,45 @@ var (
|
||||
preferredLoginNameQuery = `SELECT preferred_login_name.user_id, preferred_login_name.login_name, preferred_login_name.instance_id` +
|
||||
` FROM projections.login_names3 AS preferred_login_name` +
|
||||
` WHERE preferred_login_name.is_primary = $1`
|
||||
userQuery = `SELECT projections.users12.id,` +
|
||||
` projections.users12.creation_date,` +
|
||||
` projections.users12.change_date,` +
|
||||
` projections.users12.resource_owner,` +
|
||||
` projections.users12.sequence,` +
|
||||
` projections.users12.state,` +
|
||||
` projections.users12.type,` +
|
||||
` projections.users12.username,` +
|
||||
userQuery = `SELECT projections.users13.id,` +
|
||||
` projections.users13.creation_date,` +
|
||||
` projections.users13.change_date,` +
|
||||
` projections.users13.resource_owner,` +
|
||||
` projections.users13.sequence,` +
|
||||
` projections.users13.state,` +
|
||||
` projections.users13.type,` +
|
||||
` projections.users13.username,` +
|
||||
` login_names.loginnames,` +
|
||||
` preferred_login_name.login_name,` +
|
||||
` projections.users12_humans.user_id,` +
|
||||
` projections.users12_humans.first_name,` +
|
||||
` projections.users12_humans.last_name,` +
|
||||
` projections.users12_humans.nick_name,` +
|
||||
` projections.users12_humans.display_name,` +
|
||||
` projections.users12_humans.preferred_language,` +
|
||||
` projections.users12_humans.gender,` +
|
||||
` projections.users12_humans.avatar_key,` +
|
||||
` projections.users12_humans.email,` +
|
||||
` projections.users12_humans.is_email_verified,` +
|
||||
` projections.users12_humans.phone,` +
|
||||
` projections.users12_humans.is_phone_verified,` +
|
||||
` projections.users12_humans.password_change_required,` +
|
||||
` projections.users12_machines.user_id,` +
|
||||
` projections.users12_machines.name,` +
|
||||
` projections.users12_machines.description,` +
|
||||
` projections.users12_machines.secret,` +
|
||||
` projections.users12_machines.access_token_type,` +
|
||||
` projections.users13_humans.user_id,` +
|
||||
` projections.users13_humans.first_name,` +
|
||||
` projections.users13_humans.last_name,` +
|
||||
` projections.users13_humans.nick_name,` +
|
||||
` projections.users13_humans.display_name,` +
|
||||
` projections.users13_humans.preferred_language,` +
|
||||
` projections.users13_humans.gender,` +
|
||||
` projections.users13_humans.avatar_key,` +
|
||||
` projections.users13_humans.email,` +
|
||||
` projections.users13_humans.is_email_verified,` +
|
||||
` projections.users13_humans.phone,` +
|
||||
` projections.users13_humans.is_phone_verified,` +
|
||||
` projections.users13_humans.password_change_required,` +
|
||||
` projections.users13_humans.password_changed,` +
|
||||
` projections.users13_machines.user_id,` +
|
||||
` projections.users13_machines.name,` +
|
||||
` projections.users13_machines.description,` +
|
||||
` projections.users13_machines.secret,` +
|
||||
` projections.users13_machines.access_token_type,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.users12.id = projections.users12_humans.user_id AND projections.users12.instance_id = projections.users12_humans.instance_id` +
|
||||
` LEFT JOIN projections.users12_machines ON projections.users12.id = projections.users12_machines.user_id AND projections.users12.instance_id = projections.users12_machines.instance_id` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.users13.id = projections.users13_humans.user_id AND projections.users13.instance_id = projections.users13_humans.instance_id` +
|
||||
` LEFT JOIN projections.users13_machines ON projections.users13.id = projections.users13_machines.user_id AND projections.users13.instance_id = projections.users13_machines.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (` + loginNamesQuery + `) AS login_names` +
|
||||
` ON login_names.user_id = projections.users12.id AND login_names.instance_id = projections.users12.instance_id` +
|
||||
` ON login_names.user_id = projections.users13.id AND login_names.instance_id = projections.users13.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (` + preferredLoginNameQuery + `) AS preferred_login_name` +
|
||||
` ON preferred_login_name.user_id = projections.users12.id AND preferred_login_name.instance_id = projections.users12.instance_id` +
|
||||
` ON preferred_login_name.user_id = projections.users13.id AND preferred_login_name.instance_id = projections.users13.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
userCols = []string{
|
||||
"id",
|
||||
@@ -211,6 +212,7 @@ var (
|
||||
"phone",
|
||||
"is_phone_verified",
|
||||
"password_change_required",
|
||||
"password_changed",
|
||||
// machine
|
||||
"user_id",
|
||||
"name",
|
||||
@@ -219,21 +221,21 @@ var (
|
||||
"access_token_type",
|
||||
"count",
|
||||
}
|
||||
profileQuery = `SELECT projections.users12.id,` +
|
||||
` projections.users12.creation_date,` +
|
||||
` projections.users12.change_date,` +
|
||||
` projections.users12.resource_owner,` +
|
||||
` projections.users12.sequence,` +
|
||||
` projections.users12_humans.user_id,` +
|
||||
` projections.users12_humans.first_name,` +
|
||||
` projections.users12_humans.last_name,` +
|
||||
` projections.users12_humans.nick_name,` +
|
||||
` projections.users12_humans.display_name,` +
|
||||
` projections.users12_humans.preferred_language,` +
|
||||
` projections.users12_humans.gender,` +
|
||||
` projections.users12_humans.avatar_key` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.users12.id = projections.users12_humans.user_id AND projections.users12.instance_id = projections.users12_humans.instance_id` +
|
||||
profileQuery = `SELECT projections.users13.id,` +
|
||||
` projections.users13.creation_date,` +
|
||||
` projections.users13.change_date,` +
|
||||
` projections.users13.resource_owner,` +
|
||||
` projections.users13.sequence,` +
|
||||
` projections.users13_humans.user_id,` +
|
||||
` projections.users13_humans.first_name,` +
|
||||
` projections.users13_humans.last_name,` +
|
||||
` projections.users13_humans.nick_name,` +
|
||||
` projections.users13_humans.display_name,` +
|
||||
` projections.users13_humans.preferred_language,` +
|
||||
` projections.users13_humans.gender,` +
|
||||
` projections.users13_humans.avatar_key` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.users13.id = projections.users13_humans.user_id AND projections.users13.instance_id = projections.users13_humans.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
profileCols = []string{
|
||||
"id",
|
||||
@@ -250,16 +252,16 @@ var (
|
||||
"gender",
|
||||
"avatar_key",
|
||||
}
|
||||
emailQuery = `SELECT projections.users12.id,` +
|
||||
` projections.users12.creation_date,` +
|
||||
` projections.users12.change_date,` +
|
||||
` projections.users12.resource_owner,` +
|
||||
` projections.users12.sequence,` +
|
||||
` projections.users12_humans.user_id,` +
|
||||
` projections.users12_humans.email,` +
|
||||
` projections.users12_humans.is_email_verified` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.users12.id = projections.users12_humans.user_id AND projections.users12.instance_id = projections.users12_humans.instance_id` +
|
||||
emailQuery = `SELECT projections.users13.id,` +
|
||||
` projections.users13.creation_date,` +
|
||||
` projections.users13.change_date,` +
|
||||
` projections.users13.resource_owner,` +
|
||||
` projections.users13.sequence,` +
|
||||
` projections.users13_humans.user_id,` +
|
||||
` projections.users13_humans.email,` +
|
||||
` projections.users13_humans.is_email_verified` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.users13.id = projections.users13_humans.user_id AND projections.users13.instance_id = projections.users13_humans.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
emailCols = []string{
|
||||
"id",
|
||||
@@ -271,16 +273,16 @@ var (
|
||||
"email",
|
||||
"is_email_verified",
|
||||
}
|
||||
phoneQuery = `SELECT projections.users12.id,` +
|
||||
` projections.users12.creation_date,` +
|
||||
` projections.users12.change_date,` +
|
||||
` projections.users12.resource_owner,` +
|
||||
` projections.users12.sequence,` +
|
||||
` projections.users12_humans.user_id,` +
|
||||
` projections.users12_humans.phone,` +
|
||||
` projections.users12_humans.is_phone_verified` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.users12.id = projections.users12_humans.user_id AND projections.users12.instance_id = projections.users12_humans.instance_id` +
|
||||
phoneQuery = `SELECT projections.users13.id,` +
|
||||
` projections.users13.creation_date,` +
|
||||
` projections.users13.change_date,` +
|
||||
` projections.users13.resource_owner,` +
|
||||
` projections.users13.sequence,` +
|
||||
` projections.users13_humans.user_id,` +
|
||||
` projections.users13_humans.phone,` +
|
||||
` projections.users13_humans.is_phone_verified` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.users13.id = projections.users13_humans.user_id AND projections.users13.instance_id = projections.users13_humans.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
phoneCols = []string{
|
||||
"id",
|
||||
@@ -292,14 +294,14 @@ var (
|
||||
"phone",
|
||||
"is_phone_verified",
|
||||
}
|
||||
userUniqueQuery = `SELECT projections.users12.id,` +
|
||||
` projections.users12.state,` +
|
||||
` projections.users12.username,` +
|
||||
` projections.users12_humans.user_id,` +
|
||||
` projections.users12_humans.email,` +
|
||||
` projections.users12_humans.is_email_verified` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.users12.id = projections.users12_humans.user_id AND projections.users12.instance_id = projections.users12_humans.instance_id` +
|
||||
userUniqueQuery = `SELECT projections.users13.id,` +
|
||||
` projections.users13.state,` +
|
||||
` projections.users13.username,` +
|
||||
` projections.users13_humans.user_id,` +
|
||||
` projections.users13_humans.email,` +
|
||||
` projections.users13_humans.is_email_verified` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.users13.id = projections.users13_humans.user_id AND projections.users13.instance_id = projections.users13_humans.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
userUniqueCols = []string{
|
||||
"id",
|
||||
@@ -309,40 +311,40 @@ var (
|
||||
"email",
|
||||
"is_email_verified",
|
||||
}
|
||||
notifyUserQuery = `SELECT projections.users12.id,` +
|
||||
` projections.users12.creation_date,` +
|
||||
` projections.users12.change_date,` +
|
||||
` projections.users12.resource_owner,` +
|
||||
` projections.users12.sequence,` +
|
||||
` projections.users12.state,` +
|
||||
` projections.users12.type,` +
|
||||
` projections.users12.username,` +
|
||||
notifyUserQuery = `SELECT projections.users13.id,` +
|
||||
` projections.users13.creation_date,` +
|
||||
` projections.users13.change_date,` +
|
||||
` projections.users13.resource_owner,` +
|
||||
` projections.users13.sequence,` +
|
||||
` projections.users13.state,` +
|
||||
` projections.users13.type,` +
|
||||
` projections.users13.username,` +
|
||||
` login_names.loginnames,` +
|
||||
` preferred_login_name.login_name,` +
|
||||
` projections.users12_humans.user_id,` +
|
||||
` projections.users12_humans.first_name,` +
|
||||
` projections.users12_humans.last_name,` +
|
||||
` projections.users12_humans.nick_name,` +
|
||||
` projections.users12_humans.display_name,` +
|
||||
` projections.users12_humans.preferred_language,` +
|
||||
` projections.users12_humans.gender,` +
|
||||
` projections.users12_humans.avatar_key,` +
|
||||
` projections.users12_notifications.user_id,` +
|
||||
` projections.users12_notifications.last_email,` +
|
||||
` projections.users12_notifications.verified_email,` +
|
||||
` projections.users12_notifications.last_phone,` +
|
||||
` projections.users12_notifications.verified_phone,` +
|
||||
` projections.users12_notifications.password_set,` +
|
||||
` projections.users13_humans.user_id,` +
|
||||
` projections.users13_humans.first_name,` +
|
||||
` projections.users13_humans.last_name,` +
|
||||
` projections.users13_humans.nick_name,` +
|
||||
` projections.users13_humans.display_name,` +
|
||||
` projections.users13_humans.preferred_language,` +
|
||||
` projections.users13_humans.gender,` +
|
||||
` projections.users13_humans.avatar_key,` +
|
||||
` projections.users13_notifications.user_id,` +
|
||||
` projections.users13_notifications.last_email,` +
|
||||
` projections.users13_notifications.verified_email,` +
|
||||
` projections.users13_notifications.last_phone,` +
|
||||
` projections.users13_notifications.verified_phone,` +
|
||||
` projections.users13_notifications.password_set,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.users12.id = projections.users12_humans.user_id AND projections.users12.instance_id = projections.users12_humans.instance_id` +
|
||||
` LEFT JOIN projections.users12_notifications ON projections.users12.id = projections.users12_notifications.user_id AND projections.users12.instance_id = projections.users12_notifications.instance_id` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.users13.id = projections.users13_humans.user_id AND projections.users13.instance_id = projections.users13_humans.instance_id` +
|
||||
` LEFT JOIN projections.users13_notifications ON projections.users13.id = projections.users13_notifications.user_id AND projections.users13.instance_id = projections.users13_notifications.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (` + loginNamesQuery + `) AS login_names` +
|
||||
` ON login_names.user_id = projections.users12.id AND login_names.instance_id = projections.users12.instance_id` +
|
||||
` ON login_names.user_id = projections.users13.id AND login_names.instance_id = projections.users13.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (` + preferredLoginNameQuery + `) AS preferred_login_name` +
|
||||
` ON preferred_login_name.user_id = projections.users12.id AND preferred_login_name.instance_id = projections.users12.instance_id` +
|
||||
` ON preferred_login_name.user_id = projections.users13.id AND preferred_login_name.instance_id = projections.users13.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
notifyUserCols = []string{
|
||||
"id",
|
||||
@@ -373,44 +375,45 @@ var (
|
||||
"password_set",
|
||||
"count",
|
||||
}
|
||||
usersQuery = `SELECT projections.users12.id,` +
|
||||
` projections.users12.creation_date,` +
|
||||
` projections.users12.change_date,` +
|
||||
` projections.users12.resource_owner,` +
|
||||
` projections.users12.sequence,` +
|
||||
` projections.users12.state,` +
|
||||
` projections.users12.type,` +
|
||||
` projections.users12.username,` +
|
||||
usersQuery = `SELECT projections.users13.id,` +
|
||||
` projections.users13.creation_date,` +
|
||||
` projections.users13.change_date,` +
|
||||
` projections.users13.resource_owner,` +
|
||||
` projections.users13.sequence,` +
|
||||
` projections.users13.state,` +
|
||||
` projections.users13.type,` +
|
||||
` projections.users13.username,` +
|
||||
` login_names.loginnames,` +
|
||||
` preferred_login_name.login_name,` +
|
||||
` projections.users12_humans.user_id,` +
|
||||
` projections.users12_humans.first_name,` +
|
||||
` projections.users12_humans.last_name,` +
|
||||
` projections.users12_humans.nick_name,` +
|
||||
` projections.users12_humans.display_name,` +
|
||||
` projections.users12_humans.preferred_language,` +
|
||||
` projections.users12_humans.gender,` +
|
||||
` projections.users12_humans.avatar_key,` +
|
||||
` projections.users12_humans.email,` +
|
||||
` projections.users12_humans.is_email_verified,` +
|
||||
` projections.users12_humans.phone,` +
|
||||
` projections.users12_humans.is_phone_verified,` +
|
||||
` projections.users12_humans.password_change_required,` +
|
||||
` projections.users12_machines.user_id,` +
|
||||
` projections.users12_machines.name,` +
|
||||
` projections.users12_machines.description,` +
|
||||
` projections.users12_machines.secret,` +
|
||||
` projections.users12_machines.access_token_type,` +
|
||||
` projections.users13_humans.user_id,` +
|
||||
` projections.users13_humans.first_name,` +
|
||||
` projections.users13_humans.last_name,` +
|
||||
` projections.users13_humans.nick_name,` +
|
||||
` projections.users13_humans.display_name,` +
|
||||
` projections.users13_humans.preferred_language,` +
|
||||
` projections.users13_humans.gender,` +
|
||||
` projections.users13_humans.avatar_key,` +
|
||||
` projections.users13_humans.email,` +
|
||||
` projections.users13_humans.is_email_verified,` +
|
||||
` projections.users13_humans.phone,` +
|
||||
` projections.users13_humans.is_phone_verified,` +
|
||||
` projections.users13_humans.password_change_required,` +
|
||||
` projections.users13_humans.password_changed,` +
|
||||
` projections.users13_machines.user_id,` +
|
||||
` projections.users13_machines.name,` +
|
||||
` projections.users13_machines.description,` +
|
||||
` projections.users13_machines.secret,` +
|
||||
` projections.users13_machines.access_token_type,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.users12` +
|
||||
` LEFT JOIN projections.users12_humans ON projections.users12.id = projections.users12_humans.user_id AND projections.users12.instance_id = projections.users12_humans.instance_id` +
|
||||
` LEFT JOIN projections.users12_machines ON projections.users12.id = projections.users12_machines.user_id AND projections.users12.instance_id = projections.users12_machines.instance_id` +
|
||||
` FROM projections.users13` +
|
||||
` LEFT JOIN projections.users13_humans ON projections.users13.id = projections.users13_humans.user_id AND projections.users13.instance_id = projections.users13_humans.instance_id` +
|
||||
` LEFT JOIN projections.users13_machines ON projections.users13.id = projections.users13_machines.user_id AND projections.users13.instance_id = projections.users13_machines.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (` + loginNamesQuery + `) AS login_names` +
|
||||
` ON login_names.user_id = projections.users12.id AND login_names.instance_id = projections.users12.instance_id` +
|
||||
` ON login_names.user_id = projections.users13.id AND login_names.instance_id = projections.users13.instance_id` +
|
||||
` LEFT JOIN` +
|
||||
` (` + preferredLoginNameQuery + `) AS preferred_login_name` +
|
||||
` ON preferred_login_name.user_id = projections.users12.id AND preferred_login_name.instance_id = projections.users12.instance_id` +
|
||||
` ON preferred_login_name.user_id = projections.users13.id AND preferred_login_name.instance_id = projections.users13.instance_id` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
usersCols = []string{
|
||||
"id",
|
||||
@@ -437,6 +440,7 @@ var (
|
||||
"phone",
|
||||
"is_phone_verified",
|
||||
"password_change_required",
|
||||
"password_changed",
|
||||
// machine
|
||||
"user_id",
|
||||
"name",
|
||||
@@ -508,6 +512,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
"phone",
|
||||
true,
|
||||
true,
|
||||
testNow,
|
||||
// machine
|
||||
nil,
|
||||
nil,
|
||||
@@ -542,6 +547,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
Phone: "phone",
|
||||
IsPhoneVerified: true,
|
||||
PasswordChangeRequired: true,
|
||||
PasswordChanged: testNow,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -577,6 +583,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// machine
|
||||
"id",
|
||||
"name",
|
||||
@@ -638,6 +645,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// machine
|
||||
"id",
|
||||
"name",
|
||||
@@ -1226,6 +1234,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
"phone",
|
||||
true,
|
||||
true,
|
||||
testNow,
|
||||
// machine
|
||||
nil,
|
||||
nil,
|
||||
@@ -1265,6 +1274,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
Phone: "phone",
|
||||
IsPhoneVerified: true,
|
||||
PasswordChangeRequired: true,
|
||||
PasswordChanged: testNow,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1303,6 +1313,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
"phone",
|
||||
true,
|
||||
true,
|
||||
testNow,
|
||||
// machine
|
||||
nil,
|
||||
nil,
|
||||
@@ -1335,6 +1346,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
// machine
|
||||
"id",
|
||||
"name",
|
||||
@@ -1374,6 +1386,7 @@ func Test_UserPrepares(t *testing.T) {
|
||||
Phone: "phone",
|
||||
IsPhoneVerified: true,
|
||||
PasswordChangeRequired: true,
|
||||
PasswordChanged: testNow,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
with usr as (
|
||||
select u.id, u.creation_date, u.change_date, u.sequence, u.state, u.resource_owner, u.username, n.login_name as preferred_login_name
|
||||
from projections.users12 u
|
||||
from projections.users13 u
|
||||
left join projections.login_names3 n on u.id = n.user_id and u.instance_id = n.instance_id
|
||||
where u.id = $1
|
||||
and u.instance_id = $2
|
||||
@@ -9,7 +9,7 @@ with usr as (
|
||||
human as (
|
||||
select $1 as user_id, row_to_json(r) as human from (
|
||||
select first_name, last_name, nick_name, display_name, avatar_key, preferred_language, gender, email, is_email_verified, phone, is_phone_verified
|
||||
from projections.users12_humans
|
||||
from projections.users13_humans
|
||||
where user_id = $1
|
||||
and instance_id = $2
|
||||
) r
|
||||
@@ -17,7 +17,7 @@ human as (
|
||||
machine as (
|
||||
select $1 as user_id, row_to_json(r) as machine from (
|
||||
select name, description
|
||||
from projections.users12_machines
|
||||
from projections.users13_machines
|
||||
where user_id = $1
|
||||
and instance_id = $2
|
||||
) r
|
||||
|
Reference in New Issue
Block a user