// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . package mfa import ( "encoding/json" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils" "github.com/iwind/TeaGo/maps" ) type IndexAction struct { actionutils.ParentAction } func (this *IndexAction) Init() { this.Nav("", "", "") } func (this *IndexAction) RunGet(params struct{}) { userResp, err := this.RPC().UserRPC().FindEnabledUser(this.UserContext(), &pb.FindEnabledUserRequest{}) if err != nil { this.ErrorPage(err) return } var user = userResp.User if user == nil { this.NotFound("User", this.UserId()) return } // OTP this.Data["otp"] = nil if user.OtpLogin != nil && user.OtpLogin.IsOn { loginParams := maps.Map{} err = json.Unmarshal(user.OtpLogin.ParamsJSON, &loginParams) if err != nil { this.ErrorPage(err) return } this.Data["otp"] = maps.Map{ "isOn": true, "params": loginParams, } } this.Show() }