禅道官方默认支持通过二次开发应用的方式进行第三方应用跳转免登,具体开发文档见 https://www.zentao.net/book/zentaopmshelp/344.html
1 | // token的规则是: |
实现该跳转后,系统会自动跳转进入禅道后台配置的网站根目录,想通过外部指定登录后跳转的URL是无法实现的。
查看代码后,发现控制这块的代码,主要在zentao/module/common/model.php 中的 checkEntry 方法中的这一段
1 | $isFreepasswd = ($_GET['m'] == 'user' and strtolower($_GET['f']) == 'apilogin' and $_GET['account'] and $entry->freePasswd); |
当是免登跳转进来时,最终会跳转到 $this->config->webRoot 路径
修改方法就是,给这个跳转再加一个路径参数,存在这个参数时就跳转参数对应路径,修改后代码如下
1 | $isFreepasswd = ($_GET['m'] == 'user' and strtolower($_GET['f']) == 'apilogin' and $_GET['account'] and $entry->freePasswd); |
大功告成,后续跳转URL格式如下:
http://www.zentao.net/api.php?m=user&f=apilogin&account={账号}&code={禅道上创建的应用Code}&time={时间戳}&token=token&rurl=http://codvision.com/