Skip to content

Commit fc62d82

Browse files
authored
feat: enhance user login background handling with style support (#2462)
1 parent b8d6e2f commit fc62d82

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

framework/bfl/pkg/apis/backend/v1/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (h *Handler) handleTerminusInfo(req *restful.Request, resp *restful.Respons
281281
tInfo.TailScaleEnable = denyAll == 1
282282
}
283283

284-
tInfo.LoginBackground = userOp.GetLoginBackground(user)
284+
tInfo.LoginBackground, tInfo.Style = userOp.GetLoginBackground(user)
285285
tInfo.Avatar = userOp.GetAvatar(user)
286286
tInfo.UserDID = userOp.GetUserDID(user)
287287

@@ -347,7 +347,7 @@ func (h *Handler) handleOlaresInfo(req *restful.Request, resp *restful.Response)
347347
tInfo.TailScaleEnable = denyAll == 1
348348
}
349349

350-
tInfo.LoginBackground = userOp.GetLoginBackground(user)
350+
tInfo.LoginBackground, tInfo.Style = userOp.GetLoginBackground(user)
351351
tInfo.Avatar = userOp.GetAvatar(user)
352352
tInfo.UserDID = userOp.GetUserDID(user)
353353

framework/bfl/pkg/apis/backend/v1/model.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type TerminusInfo struct {
4040
UserDID string `json:"did"`
4141
ReverseProxy string `json:"reverseProxy"`
4242
Terminusd string `json:"terminusd"`
43+
Style string `json:"style"`
4344
}
4445

4546
type OlaresInfo struct {
@@ -53,6 +54,7 @@ type OlaresInfo struct {
5354
ID string `json:"id"`
5455
UserDID string `json:"did"`
5556
Olaresd string `json:"olaresd"`
57+
Style string `json:"style"`
5658
}
5759

5860
type MyAppsParam struct {

framework/bfl/pkg/apis/iam/v1alpha1/operator/user_operator.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,18 @@ func (o *UserOperator) GetReverseProxyType() (string, error) {
127127
return o.GetUserAnnotation(user, constants.UserAnnotationReverseProxyType), nil
128128
}
129129

130-
func (o *UserOperator) GetLoginBackground(user *iamV1alpha2.User) string {
130+
func (o *UserOperator) GetLoginBackground(user *iamV1alpha2.User) (string, string) {
131131
b := o.GetUserAnnotation(user, constants.UserLoginBackground)
132+
s := o.GetUserAnnotation(user, constants.UserLoginBackgroundStyle)
132133
if b == "" {
133-
return "/bg/0.jpg"
134+
b = "/bg/0.jpg"
134135
}
135136

136-
return b
137+
if s == "" {
138+
s = "fill"
139+
}
140+
141+
return b, s
137142
}
138143

139144
func (o *UserOperator) GetAvatar(user *iamV1alpha2.User) string {

framework/bfl/pkg/apis/settings/v1alpha1/handler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ func (h *Handler) handleUpdateLocale(req *restful.Request, resp *restful.Respons
612612
func (h *Handler) handlerUpdateUserLoginBackground(req *restful.Request, resp *restful.Response) {
613613
var background struct {
614614
Background string `json:"background"`
615+
Style string `json:"style"`
615616
}
616617

617618
err := req.ReadEntity(&background)
@@ -636,6 +637,7 @@ func (h *Handler) handlerUpdateUserLoginBackground(req *restful.Request, resp *r
636637
err = userOp.UpdateUser(user, []func(*iamV1alpha2.User){
637638
func(u *iamV1alpha2.User) {
638639
u.Annotations[constants.UserLoginBackground] = background.Background
640+
u.Annotations[constants.UserLoginBackgroundStyle] = background.Style
639641
},
640642
})
641643

framework/bfl/pkg/constants/constants.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ var (
175175

176176
UserAvatar = fmt.Sprintf("%s/avatar", AnnotationGroup)
177177

178-
UserLoginBackground = fmt.Sprintf("%s/login-background", AnnotationGroup)
178+
UserLoginBackground = fmt.Sprintf("%s/login-background", AnnotationGroup)
179+
UserLoginBackgroundStyle = fmt.Sprintf("%s/login-background-style", AnnotationGroup)
179180
)
180181

181182
var (

0 commit comments

Comments
 (0)