2021-01-05 09:33:45 +01:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/text/language"
|
2021-06-11 13:20:39 +02:00
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
2023-12-08 16:30:55 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2021-01-05 09:33:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type Profile struct {
|
|
|
|
es_models.ObjectRoot
|
|
|
|
|
|
|
|
FirstName string
|
|
|
|
LastName string
|
|
|
|
NickName string
|
|
|
|
DisplayName string
|
|
|
|
PreferredLanguage language.Tag
|
|
|
|
Gender Gender
|
|
|
|
PreferredLoginName string
|
|
|
|
LoginNames []string
|
|
|
|
}
|
2021-01-06 11:12:56 +01:00
|
|
|
|
2023-03-14 20:20:38 +01:00
|
|
|
func (p *Profile) Validate() error {
|
|
|
|
if p == nil {
|
2023-12-08 16:30:55 +02:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "PROFILE-GPY3p", "Errors.User.Profile.Empty")
|
2023-03-14 20:20:38 +01:00
|
|
|
}
|
|
|
|
if p.FirstName == "" {
|
2023-12-08 16:30:55 +02:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "PROFILE-RF5z2", "Errors.User.Profile.FirstNameEmpty")
|
2023-03-14 20:20:38 +01:00
|
|
|
}
|
|
|
|
if p.LastName == "" {
|
2023-12-08 16:30:55 +02:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "PROFILE-DSUkN", "Errors.User.Profile.LastNameEmpty")
|
2023-03-14 20:20:38 +01:00
|
|
|
}
|
|
|
|
return nil
|
2021-01-06 11:12:56 +01:00
|
|
|
}
|
2021-06-11 13:20:39 +02:00
|
|
|
|
|
|
|
func AvatarURL(prefix, resourceOwner, key string) string {
|
|
|
|
if prefix == "" || resourceOwner == "" || key == "" {
|
|
|
|
return ""
|
|
|
|
}
|
2022-02-14 17:22:30 +01:00
|
|
|
return prefix + "/" + resourceOwner + "/" + key
|
2021-06-11 13:20:39 +02:00
|
|
|
}
|