From 5404db07eb6096c8b237b9c9b5f6abdfc499e135 Mon Sep 17 00:00:00 2001 From: LawyZHENG Date: Thu, 25 Mar 2021 16:30:12 +0800 Subject: [PATCH] "dingtalk QR login" frontend --- controllers/AccountController.go | 1 + static/js/dingtalk-ddlogin.js | 18 +++++++++++++ views/account/login.tpl | 46 +++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 static/js/dingtalk-ddlogin.js diff --git a/controllers/AccountController.go b/controllers/AccountController.go index 2d3e34b1..f7e1f08b 100644 --- a/controllers/AccountController.go +++ b/controllers/AccountController.go @@ -37,6 +37,7 @@ func (c *AccountController) Prepare() { c.Data["xsrfdata"] = template.HTML(c.XSRFFormHTML()) c.Data["corpID"] = beego.AppConfig.String("dingtalk_corpid") c.Data["ENABLE_QR_DINGTALK"] = (beego.AppConfig.String("dingtalk_corpid") != "") + c.Data["dingtalk_qr_key"] = beego.AppConfig.String("dingtalk_qr_key") if !c.EnableXSRF { return diff --git a/static/js/dingtalk-ddlogin.js b/static/js/dingtalk-ddlogin.js new file mode 100644 index 00000000..f62433be --- /dev/null +++ b/static/js/dingtalk-ddlogin.js @@ -0,0 +1,18 @@ +!function (window, document) { + function d(a) { + var e, c = document.createElement("iframe"), + d = "https://login.dingtalk.com/login/qrcode.htm?goto=" + a.goto ; + d += a.style ? "&style=" + encodeURIComponent(a.style) : "", + d += a.href ? "&href=" + a.href : "", + c.src = d, + c.frameBorder = "0", + c.allowTransparency = "true", + c.scrolling = "no", + c.width = a.width ? a.width + 'px' : "365px", + c.height = a.height ? a.height + 'px' : "400px", + e = document.getElementById(a.id), + e.innerHTML = "", + e.appendChild(c) + } + window.DDLogin = d +}(window, document); \ No newline at end of file diff --git a/views/account/login.tpl b/views/account/login.tpl index a7123fd1..2129f7b5 100644 --- a/views/account/login.tpl +++ b/views/account/login.tpl @@ -72,7 +72,7 @@ {{if .ENABLE_QR_DINGTALK}}
- 钉钉扫码登录 + 钉钉扫码登录
{{end}} {{if .ENABLED_REGISTER}} @@ -83,6 +83,10 @@ {{end}} {{end}} +
@@ -92,6 +96,8 @@ + + + + +