2021-01-05 08:33:45 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/text/language"
|
2021-06-11 11:20:39 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
2023-12-08 14:30:55 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2021-01-05 08:33:45 +00: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 10:12:56 +00:00
|
|
|
|
2023-03-14 19:20:38 +00:00
|
|
|
func (p *Profile) Validate() error {
|
|
|
|
if p == nil {
|
2023-12-08 14:30:55 +00:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "PROFILE-GPY3p", "Errors.User.Profile.Empty")
|
2023-03-14 19:20:38 +00:00
|
|
|
}
|
|
|
|
if p.FirstName == "" {
|
2023-12-08 14:30:55 +00:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "PROFILE-RF5z2", "Errors.User.Profile.FirstNameEmpty")
|
2023-03-14 19:20:38 +00:00
|
|
|
}
|
|
|
|
if p.LastName == "" {
|
2023-12-08 14:30:55 +00:00
|
|
|
return zerrors.ThrowInvalidArgument(nil, "PROFILE-DSUkN", "Errors.User.Profile.LastNameEmpty")
|
2023-03-14 19:20:38 +00:00
|
|
|
}
|
|
|
|
return nil
|
2021-01-06 10:12:56 +00:00
|
|
|
}
|
2021-06-11 11:20:39 +00:00
|
|
|
|
|
|
|
func AvatarURL(prefix, resourceOwner, key string) string {
|
|
|
|
if prefix == "" || resourceOwner == "" || key == "" {
|
|
|
|
return ""
|
|
|
|
}
|
2022-02-14 16:22:30 +00:00
|
|
|
return prefix + "/" + resourceOwner + "/" + key
|
2021-06-11 11:20:39 +00:00
|
|
|
}
|