🔖 chore: profile page displays icons based on whether third-party login is enabled. (#227)

* feat(系统设置&登录): 修改飞书登录是否启用判断逻辑和设置选项

1. 系统增加是否开启飞书登录选项
2. 登录使用通过系统设置判断是否启用飞书

* perf(用户中心): 优化用户中心绑定的第三方登录是否绑定判断和展示方式

优化用户中心绑定的第三方登录是否绑定判断和展示方式:
- 系统启动了指定登录方式并且用户已经绑定该方式则icon高亮,没绑定则默认颜色显示;
- 系统没有启动指定的登录方式则不显示指定登录方式icon
This commit is contained in:
ZeroDeng
2024-05-26 12:36:55 +08:00
committed by GitHub
parent af8c249e3f
commit 2b735e6dff
8 changed files with 51 additions and 14 deletions

View File

@@ -147,6 +147,13 @@ func getLarkUserInfoByCode(code string) (*LarkUser, error) {
}
func LarkOAuth(c *gin.Context) {
if !common.LarkAuthEnabled {
c.JSON(http.StatusOK, gin.H{
"message": "管理员未开启通过飞书登录以及注册",
"success": false,
})
return
}
session := sessions.Default(c)
state := c.Query("state")
if state == "" || session.Get("oauth_state") == nil || state != session.Get("oauth_state").(string) {
@@ -220,6 +227,13 @@ func LarkOAuth(c *gin.Context) {
}
func LarkBind(c *gin.Context) {
if !common.LarkAuthEnabled {
c.JSON(http.StatusOK, gin.H{
"message": "管理员未开启通过飞书登录以及注册",
"success": false,
})
return
}
code := c.Query("code")
larkUser, err := getLarkUserInfoByCode(code)
if err != nil {

View File

@@ -28,6 +28,7 @@ func GetStatus(c *gin.Context) {
"email_verification": common.EmailVerificationEnabled,
"github_oauth": common.GitHubOAuthEnabled,
"github_client_id": common.GitHubClientId,
"lark_login": common.LarkAuthEnabled,
"lark_client_id": common.LarkClientId,
"system_name": common.SystemName,
"logo": common.Logo,