import React, { Component } from 'react';
import Particles from 'react-particles-js';
import { Form, Button } from 'antd';
import { connect } from 'react-redux';
import { setUserInfo } from '@/redux/actions/userInfo';
import '@/assets/css/login';
import * as Msal from 'msal'; //获取当前域名‘
var url = ''
function geturl() {
const href = window.location.href
console.log(href)
var reg = new RegExp(/(\w+):\/\/([^/:]+)(:\d*)?/)
let matchObj = href.match(reg)
url = matchObj[0]
// console.log(url,"--------url--------")
// // this.locationUrl = url
};
geturl()
//B2C登录
var appConfig = {
b2cScopes: ["https://XXX.onmschina.cn/api/demo.read"],//这些都要在B2C配置
webApi: "http://localhost:5000/hello"
};
// configuration to initialize msal
const msalConfig = {
auth: {
clientId: "", //This is your client ID
authority: "https://XXX.b2clogin.cn/XXX.onmschina.cn/B2C_1A_signup_signin_phone", //This is your tenant info
validateAuthority: false,
},
cache: {
cacheLocation: "localStorage",
storeAuthStateInCookie: true
}
}; // instantiate MSAL
const myMSALObj = new Msal.UserAgentApplication(msalConfig);
myMSALObj.handleRedirectCallback((error, response) => {
console.log(response, error)
if (response.idToken !== null) {
localStorage.setItem('isLogin', '1');
localStorage.setItem('menukey',[1]) localStorage.setItem('token', response.idToken.rawIdToken); window.location.href = url+"/#/dashboard"
}
else {
window.location.href = url+"/#/login"
} // handle redirect response or error
});
// request to signin - returns an idToken
const loginRequest = {
scopes: appConfig.b2cScopes
}; // request to acquire a token for resource access
const tokenRequest = {
scopes: appConfig.b2cScopes
}; const FormItem = Form.Item;
class Login extends Component {
state = { clientHeight: document.documentElement.clientHeight || document.body.clientHeight };
constructor(props) {
super(props);
this.onResize = this.onResize.bind(this);
} signIn() {
myMSALObj.loginRedirect(appConfig.b2cScopes)
}
componentDidMount() {
window.addEventListener('resize', this.onResize);
}
componentWillUnmount() {
window.addEventListener('resize', this.onResize);
// componentWillMount进行异步操作时且在callback中进行了setState操作时,需要在组件卸载时清除state
this.setState = () => {
return;
};
}
onResize() {
this.setState({ clientHeight: document.documentElement.clientHeight || document.body.clientHeight });
}
render() {
const { getFieldDecorator } = this.props.form;
return (
<div className="container">
<Particles
height={this.state.clientHeight - 5 + 'px'}
params={{
particles: {
line_linked: {
color: "#77a3fc",
},
color: {
value: "#77a3fc"
},
size: { value: 3 }
},
interactivity: {
events: {
onhover: { enable: true, mode: 'repulse' }
}
}
}}
/>
<div className="content1">
<div className="logo1"><img src='' /></div>
<div className="title1">欢迎使用ABB后台管理系统!</div>
<Form className="login-form"> <FormItem>
<Button className="button1" type="danger" htmlType="submit" block onClick={this.signIn}>
点击进入
</Button>
{/* <div style={{ color: '#999',paddingTop:'10px',textAlign:'center' }}>Tips : 输入任意用户名密码即可</div> */}
</FormItem>
</Form>
</div>
</div>
);
}
} const mapStateToProps = state => state;
const mapDispatchToProps = dispatch => ({
setUserInfo: data => {
dispatch(setUserInfo(data));
}
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(Form.create()(Login));

Azure B2C登录,react-web端实现,自定义登录页面ui的更多相关文章

  1. IPMI相关漏洞利用及WEB端默认口令登录漏洞

    IPMI相关漏洞 0套件漏洞 使用0套件时,只需要Username,口令任意即可绕过身份鉴别执行指令.而且一般还有一个默认的账户admin或者ADMIN. 备注:IPMI是一套主机远程管理系统,可以远 ...

  2. web端调百度地图页面

    在点击进入地图的入口(下面数据是vue渲染的数据) <a class="navigation" v-if="merchant.longitude && ...

  3. Web Api跨域登录问题

    最近项目第一次尝试使用web api,照搬了一般mvc的Forms登录方式,在和前端对接的时候出现一个问题: 前端使用ajax调用登录接口完成登录后,再调用别的接口,被判断为未登录. 如果直接在浏览器 ...

  4. 【Azure 应用服务】App Service中,为Java应用配置自定义错误页面,禁用DELETE, PUT方法

    问题定义 使用Azure应用服务(App Service),部署Java应用,使用Tomcat容器,如何自定义错误页面呢?同时禁用DELETE, PUT方法 解决办法 如何自定义错误页面呢?需要在 J ...

  5. FineReport中如何自定义登录界面

    在登录平台时,不希望使用FR默认的内置登录界面,想通过自定义登录界面实现登录操作,内置登录界面如下图: 登录界面,获取到用户名和密码的值,发送到报表系统,报表服务带着这两个参数访问认证地址进行认证. ...

  6. 移动web端的react.js组件化方案

     背景: 随着互联网世界的兴起,web前端开发的方式越来越多,出现了很多种场景开发的前端架构体系,也对前端的要求日益增高,早已经不是靠一个JQuery.js来做前端页面的时代了,而今移动端变化最大,近 ...

  7. react网页版聊天|仿微信、微博web版|react+pc端仿微信实例

    一.项目介绍 基于react+react-dom+react-router-dom+redux+react-redux+webpack2.0+nodejs等技术混合开发的仿微信web端聊天室react ...

  8. cas sso单点登录系列3_cas-server端配置认证方式实践(数据源+自定义java类认证)

    转:http://blog.csdn.net/ae6623/article/details/8851801 本篇将讲解cas-server端的认证方式 1.最简单的认证,用户名和密码一致就登录成功 2 ...

  9. 10行代码搞定移动web端自定义tap事件

    发发牢骚 移动web端里摸爬滚打这么久踩了不少坑,有一定移动web端经验的同学一定被click困扰过.我也不列外.一路走来被虐的不行,fastclick.touchend.iscroll什么的都用过, ...

  10. 技术实践丨React Native 项目 Web 端同构

    摘要:尽管 React Native 已经进入开源的第 6 个年头,距离发布 1.0 版本依旧是遥遥无期."Learn once, write anywhere",完全不影响 Re ...

随机推荐

  1. mac使用brew安装mysql5.7

    安装mysql5.7 brew install mysql@5.7 设置环境变量(可能安装完自动生成过了,可以cat ~/.zshrc看一下,有了就不用添加了 ) echo 'export PATH= ...

  2. 深入理解PHP之数组(遍历顺序)

    作者: Laruence 本文地址: http://www.laruence.com/2009/08/23/1065.html 转载请注明出处 经常会有人问我, PHP的数组, 如果用foreach来 ...

  3. docker中安装宝塔面板教程

    本人电脑是win10,安装的virtualbox,装的centos7.2,在centos7.2装了docker,这个比较简单,网上一大堆教程,今天说一下装好了docker之后怎么在docker中安装面 ...

  4. SpringCloudAlibaba实战教程系列

    一.简介 Spring Cloud Alibaba 致力于提供微服务开发的一站式解决方案.此项目包含开发分布式应用服务的必需组件,方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开 ...

  5. 推荐3个Python初学者学习Python案例

    回复资料,获取最新的Python的资料.想学习Python可以加微信回复报名. 希望今天的分享3个小案例,对你学习Python有帮助 Python 九九乘法表 以下实例演示了如何实现九九乘法表: 实例 ...

  6. 在服务器上发布第一个.net项目

    作为一名前端开发者,对后端一窍不通可是不行的.公司后端所用的恰好是.net技术,日常开发常见MVC架构,然而还是对MVC不甚了解,前端开发也多有掣肘.本人很想摸索清楚如何构建一个asp.net的项目, ...

  7. Golang Context 的原理与实战

    本文让我们一起来学习 golang Context 的使用和标准库中的Context的实现. golang context 包 一开始只是 Google 内部使用的一个 Golang 包,在 Gola ...

  8. Ubuntu上安装配置Java环境

    参考文献:在Ubuntu 14.04中安装JDK 方法一: @ 安装 1. 添加PPA repository系统 PPA repository介绍 $sudo add-apt-repository p ...

  9. DP背包(一)

    01背包 for(int i=0;i<n;i++) //遍历每一件物品 for(int j=v;j>=wei[i];j--)//遍历背包容量,表示在上一层的基础上,容量为J时,第i件物品装 ...

  10. Python(Pyautogui 模块)

    1.安装 pyautogui 模块 pip install pyautogui 2.pyautogui 模块相关操作 鼠标操作 # 获取屏幕宽和高 w,h = pyautogui.size() # 在 ...