ODOO阿里钉钉桌面和移动客户端免登认证通用模板
钉钉的免登接口是先要通过基于前端H5的JSAPI获取到code后才能进行后台服务端校验,但其PC端和手机端开发很可能是两个不同风格的小团队耦合而成,所以调用接口需要整合一下才能对外透明,也难怪后台应用针对两端的首页都可以分别进行配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<template id="entry" name="renjie_dingtalk entry"> <t t-call="web.layout"> <t t-set="head"> <script t-if="type == 'mobile'" type="text/javascript" src="//g.alicdn.com/dingding/open-develop/1.9.0/dingtalk.js"></script> <script t-if="type == 'pc'" type="text/javascript" src="//g.alicdn.com/dingding/dingtalk-pc-api/2.7.0/index.js"></script> </t> <script type="text/javascript"> /** * author: i@renjie.me */ var auth = { corpId: "<t t-raw="corp_id"/>", onSuccess: function(ret){ location.href = "/auth_dingtalk/sso" + location.search + "\u0026code=" + ret.code + "\u0026state=<t t-raw="state"/>"; }, onFail: function(err){} }; <t t-if="type == 'mobile'"> dd.ready(function(){ dd.runtime.permission.requestAuthCode(auth); }); </t> <t t-if="type == 'pc'"> DingTalkPC.runtime.permission.requestAuthCode(auth); </t> </script> </t> </template> |