门户定制案例-使用第三方登录页

案例需求

第三方系统登录后,点击平台链接,实现免密码登录

实现第三方系统登录校验

实现方法

  1. 定制企业门户应用,参考《门户定制
  2. 在登录页 /entry/pcxapp/pcx/user/login.w 中,数据初始化方法 onInitState 的 before 扩展点,验证是否登录
    1. 如果没有登录,跳转到第三方登录页,登录第三方后执行登录回调,在登录回调中完成平台的登录,再跳转到平台地址
    2. 如果已经登录,系统忽略登录页,直接打开门户页
  3. 编写登录回调服务,详细实现可参考《OAuth2 标准集成方案

添加扩展点

桌面端门户的扩展点方法写在 /UI2/comp/portalConfig/components/portalConfig/portalConfig.config.pc.js 文件的 onConfigContextInit 方法中,如果没有 portalConfig.config.pc.js 文件,将 portalConfig.config.js 文件复制为 portalConfig.config.pc.js 文件

添加登录页 /entry/pcxapp/pcx/user/login.w 数据初始化方法 onInitState 的 before 扩展点,代码如下

完整代码

/UI2/comp/portalConfig/components/portalConfig/portalConfig.config.pc.js 文件的完整代码如下

import { merge } from "lodash";
import ConfigContextProcessor from 'core/framework/ConfigContextProcessor';
import UserInstance from '$UI/wxsys/comps/uixContainer/UserImplement';
import React from 'react';

export default {

    processConfigContext(configContext) {
    },

    async onConfigContextInit(configContextProcessor) {
        //获取当前页
        let _this = configContextProcessor.page;

        let portalConfig = {
            "config": {  
                "/entry": {
                    "/pcxapp": {
                        "/pcx": {  
                            "/user":{
                                "/login.w": {
                                    "onInitState": {
                                        "@before":async()=>{
                                            try {
                                                //判断用户是否登录
                                                let userInfo=await UserInstance.checkLogin(_this);
                                            } catch (error) {
                                                //用户没有登录,跳转到第三方登录页面
                                                //window.top.location="https://baidu.com";
                                                //let res=await this.request({url:"http://cas认证",method:"post"});
                                            }
                                        }
                                    }
                                }
                            }   
                        }
                    }
                }  
            }
        };
        //处理自定义内容
        merge(_this.configContext, portalConfig);
        ConfigContextProcessor.enhancePageAdvice(_this);
    }
}

results matching ""

    No results matching ""