Add explicit sign in button for netlify identity
This commit is contained in:
parent
aaa9d2ab95
commit
2e4dfb33b6
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "netlify-cms",
|
"name": "netlify-cms",
|
||||||
"version": "0.5.0-beta.5",
|
"version": "0.5.0-beta.7",
|
||||||
"description": "Netlify CMS lets content editors work on structured content stored in git",
|
"description": "Netlify CMS lets content editors work on structured content stored in git",
|
||||||
"main": "dist/cms.js",
|
"main": "dist/cms.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import Input from "react-toolbox/lib/input";
|
import Input from "react-toolbox/lib/input";
|
||||||
import Button from "react-toolbox/lib/button";
|
import Button from "react-toolbox/lib/button";
|
||||||
|
import { Notifs } from 'redux-notifications';
|
||||||
|
import { Toast } from '../../components/UI/index';
|
||||||
import { Card, Icon } from "../../components/UI";
|
import { Card, Icon } from "../../components/UI";
|
||||||
import logo from "./netlify_logo.svg";
|
import logo from "./netlify_logo.svg";
|
||||||
import styles from "./AuthenticationPage.css";
|
import styles from "./AuthenticationPage.css";
|
||||||
@ -19,15 +21,13 @@ if (window.netlifyIdentity) {
|
|||||||
export default class AuthenticationPage extends React.Component {
|
export default class AuthenticationPage extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
component = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
component = this;
|
|
||||||
if (!this.loggedIn && window.netlifyIdentity && window.netlifyIdentity.currentUser()) {
|
if (!this.loggedIn && window.netlifyIdentity && window.netlifyIdentity.currentUser()) {
|
||||||
this.props.onLogin(window.netlifyIdentity.currentUser());
|
this.props.onLogin(window.netlifyIdentity.currentUser());
|
||||||
}
|
window.netlifyIdentity.close();
|
||||||
if (window.netlifyIdentity && !window.netlifyIdentity.currentUser()) {
|
|
||||||
window.netlifyIdentity.open('login');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,6 @@ export default class AuthenticationPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleIdentityLogin = (user) => {
|
handleIdentityLogin = (user) => {
|
||||||
console.log('logging in ', user);
|
|
||||||
this.props.onLogin(user);
|
this.props.onLogin(user);
|
||||||
window.netlifyIdentity.close();
|
window.netlifyIdentity.close();
|
||||||
}
|
}
|
||||||
@ -45,6 +44,14 @@ export default class AuthenticationPage extends React.Component {
|
|||||||
window.netlifyIdentity.open();
|
window.netlifyIdentity.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleIdentity = () => {
|
||||||
|
if (window.netlifyIdentity.currentUser()) {
|
||||||
|
this.props.onLogin(user);
|
||||||
|
} else {
|
||||||
|
window.netlifyIdentity.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onLogin: React.PropTypes.func.isRequired,
|
onLogin: React.PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
@ -64,7 +71,7 @@ export default class AuthenticationPage extends React.Component {
|
|||||||
errors.email = 'Make sure to enter your user name';
|
errors.email = 'Make sure to enter your user name';
|
||||||
}
|
}
|
||||||
if (!password) {
|
if (!password) {
|
||||||
errors.password = 'Please enter your password.';
|
errors.password = 'Please enter your password';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(errors).length > 0) {
|
if (Object.keys(errors).length > 0) {
|
||||||
@ -86,7 +93,12 @@ export default class AuthenticationPage extends React.Component {
|
|||||||
const { error } = this.props;
|
const { error } = this.props;
|
||||||
|
|
||||||
if (window.netlifyIdentity) {
|
if (window.netlifyIdentity) {
|
||||||
return null;
|
return <section className={styles.root}>
|
||||||
|
<Notifs CustomComponent={Toast} />
|
||||||
|
<Button className={styles.button} raised onClick={this.handleIdentity}>
|
||||||
|
Login with Netlify Identity
|
||||||
|
</Button>
|
||||||
|
</section>
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user