mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
e7b139ba2c
* fix: add preferred login name to my user sessions and get user info from view * fix: my user in auth
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package grpc
|
|
|
|
import (
|
|
auth_req_model "github.com/caos/zitadel/internal/auth_request/model"
|
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
|
)
|
|
|
|
func userSessionViewsFromModel(userSessions []*usr_model.UserSessionView) []*UserSessionView {
|
|
converted := make([]*UserSessionView, len(userSessions))
|
|
for i, s := range userSessions {
|
|
converted[i] = userSessionViewFromModel(s)
|
|
}
|
|
return converted
|
|
}
|
|
|
|
func userSessionViewFromModel(userSession *usr_model.UserSessionView) *UserSessionView {
|
|
return &UserSessionView{
|
|
Sequence: userSession.Sequence,
|
|
AgentId: userSession.UserAgentID,
|
|
UserId: userSession.UserID,
|
|
UserName: userSession.UserName,
|
|
LoginName: userSession.LoginName,
|
|
DisplayName: userSession.DisplayName,
|
|
AuthState: userSessionStateFromModel(userSession.State),
|
|
}
|
|
}
|
|
|
|
func userSessionStateFromModel(state auth_req_model.UserSessionState) UserSessionState {
|
|
switch state {
|
|
case auth_req_model.UserSessionStateActive:
|
|
return UserSessionState_USERSESSIONSTATE_ACTIVE
|
|
case auth_req_model.UserSessionStateTerminated:
|
|
return UserSessionState_USERSESSIONSTATE_TERMINATED
|
|
default:
|
|
return UserSessionState_USERSESSIONSTATE_UNSPECIFIED
|
|
}
|
|
}
|