feat: ResetPassword endpoint

This commit is contained in:
Stefan Benz
2024-09-24 21:01:52 +02:00
parent 50e0c758de
commit 48b0d20e51
3 changed files with 8 additions and 36 deletions

View File

@@ -210,7 +210,7 @@ func TestCommands_CreateDebugEvents(t *testing.T) {
}},
want: &domain.ObjectDetails{
ResourceOwner: "instance1",
ID: "dgb1",
ID: "dbg1",
},
},
{
@@ -244,7 +244,7 @@ func TestCommands_CreateDebugEvents(t *testing.T) {
}},
want: &domain.ObjectDetails{
ResourceOwner: "instance1",
ID: "dgb1",
ID: "dbg1",
},
},
{
@@ -277,7 +277,7 @@ func TestCommands_CreateDebugEvents(t *testing.T) {
}},
want: &domain.ObjectDetails{
ResourceOwner: "instance1",
ID: "dgb1",
ID: "dbg1",
},
},
{
@@ -327,7 +327,7 @@ func TestCommands_CreateDebugEvents(t *testing.T) {
}},
want: &domain.ObjectDetails{
ResourceOwner: "instance1",
ID: "dgb1",
ID: "dbg1",
},
},
}

View File

@@ -194,7 +194,7 @@ func (c *Commands) getSchemaUserPasswordWithVerification(ctx context.Context, us
}
// ...or old password
if user.CurrentPassword != "" {
verification = c.checkCurrentPassword(user.Password, user.EncodedPasswordHash, user.CurrentPassword, writeModel.EncodedHash)
verification = c.checkSchemaUserCurrentPassword(user.Password, user.EncodedPasswordHash, user.CurrentPassword, writeModel.EncodedHash)
}
if verification != nil {
@@ -242,9 +242,9 @@ func (c *Commands) checkSchemaUserCurrentPassword(
) setPasswordVerification {
// in case the new password is already encoded, we only need to verify the current
if newEncodedPassword != "" {
return func(ctx context.Context) (_ string, err error) {
return func(ctx context.Context) (string, error) {
_, spanPasswap := tracing.NewNamedSpan(ctx, "passwap.Verify")
_, err = c.userPasswordHasher.Verify(currentEncodePassword, currentPassword)
_, err := c.userPasswordHasher.Verify(currentEncodePassword, currentPassword)
spanPasswap.EndWithError(err)
return "", convertPasswapErr(err)
}

View File

@@ -78,34 +78,6 @@ func (c *Commands) getSchemaUsernameExistsWithPermission(ctx context.Context, re
return writeModel, nil
}
func existingSchemaUser(ctx context.Context, c *Commands, resourceOwner, userID string) (*UserV3WriteModel, error) {
if userID == "" {
return nil, zerrors.ThrowInvalidArgument(nil, "COMMAND-aS3Vz5t6BS", "Errors.IDMissing")
}
existingUser, err := c.getSchemaUserExists(ctx, resourceOwner, userID)
if err != nil {
return nil, err
}
if !existingUser.Exists() {
return nil, zerrors.ThrowNotFound(nil, "COMMAND-6T2xrOHxTx", "Errors.User.NotFound")
}
if err := c.checkPermissionUpdateUser(ctx, existingUser.ResourceOwner, existingUser.AggregateID); err != nil {
return nil, err
}
existingSchema, err := c.getSchemaWriteModelByID(ctx, "", existingUser.SchemaID)
if err != nil {
return nil, err
}
if !existingSchema.Exists() {
return nil, zerrors.ThrowNotFound(nil, "COMMAND-6T2xrOHxTx", "TODO")
}
//TODO possible authenticators check
return existingUser, nil
}
func existingSchemaUserWithPermission(ctx context.Context, c *Commands, resourceOwner, userID string) (*UserV3WriteModel, error) {
if userID == "" {
return nil, zerrors.ThrowInvalidArgument(nil, "COMMAND-aS3Vz5t6BS", "Errors.IDMissing")
@@ -130,6 +102,6 @@ func existingSchemaUserWithPermission(ctx context.Context, c *Commands, resource
return nil, zerrors.ThrowNotFound(nil, "COMMAND-6T2xrOHxTx", "TODO")
}
//TODO possible authenticators check
// TODO possible authenticators check
return existingUser, nil
}