mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-30 17:00:57 -06:00
Instead of trying to guess names, ignore them.
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Nerzal/gocloak/v13"
|
||||
"github.com/google/uuid"
|
||||
@@ -74,17 +73,14 @@ func (b Backend) CreateUser(ctx context.Context, invitation *invitations.Invitat
|
||||
}
|
||||
u := uuid.New()
|
||||
|
||||
firstName, lastName := splitDisplayName(invitation.InvitedUserDisplayName)
|
||||
b.logger.Info().
|
||||
Str(idAttr, u.String()).
|
||||
Str("email", invitation.InvitedUserEmailAddress).
|
||||
Msg("Creating new user")
|
||||
user := gocloak.User{
|
||||
FirstName: &firstName,
|
||||
LastName: &lastName,
|
||||
Email: &invitation.InvitedUserEmailAddress,
|
||||
Enabled: gocloak.BoolP(true),
|
||||
Username: &invitation.InvitedUserEmailAddress,
|
||||
Email: &invitation.InvitedUserEmailAddress,
|
||||
Enabled: gocloak.BoolP(true),
|
||||
Username: &invitation.InvitedUserEmailAddress,
|
||||
Attributes: &map[string][]string{
|
||||
idAttr: {u.String()},
|
||||
userTypeAttr: {userTypeVal},
|
||||
@@ -142,14 +138,3 @@ func (b Backend) getToken(ctx context.Context) (*gocloak.JWT, error) {
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
||||
// Quick and dirty way to split the last name off from the first name(s), imperfect, because
|
||||
// every culture has a different conception of names.
|
||||
func splitDisplayName(displayName string) (string, string) {
|
||||
parts := strings.Split(displayName, " ")
|
||||
if len(parts) <= 1 {
|
||||
return parts[0], ""
|
||||
}
|
||||
|
||||
return strings.Join(parts[:len(parts)-1], " "), parts[len(parts)-1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user