bsvveen / react-openidconnect Goto Github PK
View Code? Open in Web Editor NEWSimple React OpenIdConnect component
Simple React OpenIdConnect component
i am currently using react with typescript. It currently works in all other browsers except for IE 11. It throws error as:
"Objects are not valid as a React child (found: object with keys {$$typeof, type, key, ref, props, _owner}). If you meant to render a collection of children, use an array instead." the code that i have is:
import React, { useState, useEffect } from "react";
import $ from "jquery";
import { default as OidcSettings } from "../../oidcsettings.json";
import { useDispatch, connect } from "react-redux";
import { getlogin } from "../../redux/login/action";
import { RootReducerState } from "../../redux/rootReducer";
import { loginState } from "../../redux/login/reducer";
import { useHistory } from "react-router-dom";
import Authenticate from "react-openidconnect";
// const Authenticate = require("react-openidconnect");
interface Props {
loginState: loginState;
}
const Login = ({ loginState }: Props) => {
const { isLoggedIn } = loginState;
const history = useHistory();
const [user, setUser] = useState(undefined);
const dispatch = useDispatch();
function userLoaded(user: any) {
if (user) setUser(user);
}
function userUnLoaded() {
setUser(undefined);
}
// @note This function is optional. If you not pass it will looks for "#id_token" in the URL
function checkAuthentication() {
return window.location.href.includes("code");
}
function NotAuthenticated() {
if (OidcSettings.autoLogin && !window.location.href.includes("code")) {
setTimeout(() => {
let ele = $("#btn");
ele.click();
});
return <div id="btn"></div>;
} else if (
OidcSettings.autoLogin &&
window.location.href.includes("code")
) {
return <div id="btn"></div>;
} else {
return (
<div className="banner">
<div className="banner-content">
<h3>
Welcome to <img src="images/logo/ncell-logo.png" />
</h3>
<button id="btn" className="btn btn-primary">
<i className="fa fa-sign-in"></i>Log in
</button>
</div>
</div>
);
}
}
useEffect(() => {
if (window.location.href.includes("code")) {
let code = window.location.href.split("=")[1].split("&")[0];
login(code);
}
}, []);
function login(code: string) {
// evt.preventDefault();
// let { username, password } = this.state;
dispatch(getlogin("username", "password", code));
return false;
}
return (
const mapStateToProps = (state: RootReducerState) => {
return {
loginState: state.loginReducer,
};
};
export default connect(mapStateToProps)(Login);
can you think of any possible reason that why it is throwing error in IE only??
Hello,
Nice project! Do you plan to add support for typescript soon or later ?
Thanks in advance.
I'm using an identity OAUTH server that returns an access_token. is this why userLoaded is not getting called? If not, any ideas why this isn't called?
Hi,
Is there a way to invoke the authentication redirect without displaying the message and user click on the div specified for renderNotAuthenticated?
Thanks,
Hi- Please could you confirm under which Opensource license is this code available?
Thank you, Neha Sompura
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.