MSP-1538 use GivenName as role id

This commit is contained in:
d1slike committed 2023-04-05 18:12:40 +03:00
1 parent abcf2162a7
commit 0877e05811
2 files changed
+11 -5

No files matched your search

-1
View File
@@ -20,7 +20,6 @@ linters:
- govet
- nakedret
- nestif
- nolintlint
- prealloc
- rowserrcheck
- staticcheck
+11 -4
View File
@@ -59,28 +59,35 @@ func (s Sudir) Authenticate(ctx context.Context, authCode string) (*entity.Sudir
return nil, errors.WithMessage(user.SudirAuthError, "get user")
}
role := getRole(user.Groups)
//nolint
/*role := getRole(user.Groups)
if role == "" {
return nil, errors.New("undefined role")
}
}*/
roleId, err := s.roleRepo.UpsertRoleByName(ctx, entity.Role{
Name: role,
Name: user.GivenName,
Rights: map[string]string{},
})
if err != nil {
return nil, errors.WithMessage(err, "upsert role")
}
email := user.Email
if email == "" {
email = user.Sub
}
return &entity.SudirUser{
RoleId: roleId,
SudirUserId: user.Sub,
FirstName: user.GivenName,
LastName: user.FamilyName,
Email: user.Email,
Email: email,
}, nil
}
// nolint
func getRole(groups []string) string {
for _, group := range groups {
part := strings.Split(group, ",")