Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature/split login strategies #1053

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0bec6ba
split-login-styles (3th-party)
Oct 19, 2016
de55aed
split facebook strategie
Oct 19, 2016
a5f0a1f
move login form to
Oct 19, 2016
51973d6
fix code style and remove duplicate css code
Oct 19, 2016
8f1272b
remove duplicate code and use only one components for each 3rd party
Oct 21, 2016
ed6896a
fix coding style
Oct 21, 2016
c985f87
refactor because css d property are currently not cross browser compa…
Oct 21, 2016
38f15ed
fix typo
Dec 19, 2016
6afe538
Merge commit '2a293f506a1e4a8bc381b6a790a0b47b4d1bab57' into feature/…
Dec 19, 2016
b053e64
fix merge conflict
Dec 19, 2016
186ba7c
move full initialize progress into password.js file
ClemensSahs Dec 27, 2016
b0f57cc
Merge commit '78868e6c7bcd64717e0b7f637f3a880f30d64cf7' into feature/…
ClemensSahs Dec 27, 2016
e6e6ed8
refactor separate strategy
ClemensSahs Jan 31, 2017
1a0fff8
fix eslint
ClemensSahs Jan 31, 2017
b3356f7
remove eslint env
ClemensSahs Jan 31, 2017
dc07ab6
refactor all as promises
ClemensSahs Feb 1, 2017
48e252a
Merge commit 'a55d311492b82dc6db19f3100d0a1b0b214d8fb9' into feature/…
ClemensSahs Feb 1, 2017
a3021db
Merge commit 'a55d311492b82dc6db19f3100d0a1b0b214d8fb9' into feature/…
ClemensSahs Feb 1, 2017
125e41f
temp eslint disable
ClemensSahs Feb 1, 2017
a4d1ab2
Merge branch 'feature/split-login-styles' into feature/split-login-st…
ClemensSahs Feb 1, 2017
00d7de3
first run
ClemensSahs Feb 4, 2017
0beaa0f
run with graphql
ClemensSahs Feb 6, 2017
b006af2
fix routing order
ClemensSahs Feb 6, 2017
102c3d4
add github logic
ClemensSahs Feb 6, 2017
630a8e8
Merge branch 'master' of github.com:kriasoft/react-starter-kit into f…
ClemensSahs Feb 6, 2017
d11c5ef
passport strategy: Facebook
Feb 7, 2017
262deb3
fix typo
Feb 7, 2017
30d9c49
add cleaned github oauth logic
ClemensSahs Feb 7, 2017
c47c13b
remove duplicate code
ClemensSahs Feb 7, 2017
a8b64d6
remove eslint WIP comments
ClemensSahs Feb 7, 2017
1302162
fix
Feb 8, 2017
1622430
fix io timing
ClemensSahs Feb 15, 2017
0509b8a
fix typo
ClemensSahs Feb 15, 2017
efe2a55
Merge commit '52899e83f83255b8f30968396f3300e8c1b6c3fd' into feature/…
ClemensSahs Feb 15, 2017
bbe7783
refactor login third party component
ClemensSahs Feb 26, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ forked repo, check that it meets these guidelines:
* Create a separate PR for each small feature or bug fix.
* [Squash](http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git)
your commits into one for each PR.
* Run `yarn test` to make sure that your code style is OK and there are no any regression bugs.
* Run `yarn test` to make sure that your code style is OK and there are no any regression bugs.
* When contributing to an opt-in feature, apply the `[feature/...]` tag as a prefix to your PR title

#### Style Guide
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-configure-text-editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ yarn add --dev eslint babel-eslint eslint-plugin-react stylelint

### SublimeText

Install SublimeText packages
Easiest with [Package Control](https://packagecontrol.io/) and then "Package Control: Install Package" (Ctrl+Shift+P)
Install SublimeText packages
Easiest with [Package Control](https://packagecontrol.io/) and then "Package Control: Install Package" (Ctrl+Shift+P)

* [Babel](https://packagecontrol.io/packages/Babel)
* [Sublime-linter](http://www.sublimelinter.com/en/latest/)
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/how-to-integrate-react-intl.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ the [`defineMessages()`](https://github.com/yahoo/react-intl/wiki/API#definemess
[`<FormattedDate>`](https://github.com/yahoo/react-intl/wiki/Components#formatteddate)
[`<FormattedTime>`](https://github.com/yahoo/react-intl/wiki/Components#formattedtime)
[`<FormattedRelative>`](https://github.com/yahoo/react-intl/wiki/Components#formattedrelative)

- For numbers and currencies:
[`<FormattedNumber>`](https://github.com/yahoo/react-intl/wiki/Components#formattednumber)
[`<FormattedPlural>`](https://github.com/yahoo/react-intl/wiki/Components#formattedplural)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"normalize.css": "^5.0.0",
"passport": "^0.3.2",
"passport-facebook": "^2.1.1",
"passport-github2": "^0.1.10",
"pretty-error": "^2.0.2",
"query-string": "^4.3.1",
"react": "^15.4.2",
Expand Down
44 changes: 44 additions & 0 deletions src/components/LoginForm/Button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/

.button {
display: block;
box-sizing: border-box;
margin: 0;
padding: 10px 16px;
width: 100%;
outline: 0;
border: 1px solid #373277;
border-radius: 0;
background: #373277;
color: #fff;
text-align: center;
text-decoration: none;
font-size: 18px;
line-height: 1.3333333;
cursor: pointer;
}

.button:hover {
background: rgba(54, 50, 119, 0.8);
}

.button:focus {
border-color: #0074c2;
box-shadow: 0 0 8px rgba(0, 116, 194, 0.6);
}

.icon {
display: inline-block;
margin: -2px 12px -2px 0;
width: 20px;
height: 20px;
vertical-align: middle;
fill: currentColor;
}
43 changes: 43 additions & 0 deletions src/components/LoginForm/LoginForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
@import '../variables.css';
@import '../LoginForm/Button.css';

.formGroup {
margin-bottom: 15px;
}

.label {
display: inline-block;
margin-bottom: 5px;
max-width: 100%;
font-weight: 700;
}

.input {
display: block;
box-sizing: border-box;
padding: 10px 16px;
width: 100%;
height: 46px;
outline: 0;
border: 1px solid #ccc;
border-radius: 0;
background: #fff;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
color: #616161;
font-size: 18px;
line-height: 1.3333333;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}

.input:focus {
border-color: #0074c2;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(0, 116, 194, 0.6);
}
50 changes: 50 additions & 0 deletions src/components/LoginForm/LoginForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* eslint-disable css-modules/no-undef-class */
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/

import React from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './LoginForm.css';

function LoginForm() {
return (
<form method="post">
<div className={s.formGroup}>
<label className={s.label} htmlFor="usernameOrEmail">
Username or email address:
</label>
<input
className={s.input}
id="usernameOrEmail"
type="text"
name="usernameOrEmail"
autoFocus
/>
</div>
<div className={s.formGroup}>
<label className={s.label} htmlFor="password">
Password:
</label>
<input
className={s.input}
id="password"
type="password"
name="password"
/>
</div>
<div className={s.formGroup}>
<button className={s.button} type="submit">
Log in
</button>
</div>
</form>
);
}

export default withStyles(s)(LoginForm);
6 changes: 6 additions & 0 deletions src/components/LoginForm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "LoginForm",
"version": "0.0.0",
"private": true,
"main": "./LoginForm.js"
}
84 changes: 84 additions & 0 deletions src/components/LoginThirdParty/LoginThirdParty.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
@import '../variables.css';
@import '../LoginForm/Button.css';

.facebook {
border-color: #3b5998;
background: #3b5998;
composes: button;
}

.facebook:hover {
background: #2d4373;
}

.google {
border-color: #dd4b39;
background: #dd4b39;
composes: button;
}

.google:hover {
background: #c23321;
}

.twitter {
border-color: #55acee;
background: #55acee;
composes: button;
}

.twitter:hover {
background: #2795e9;
}

.github {
border-color: #497e71;
background: #497e71;
composes: button;
}

.github:hover {
background: #257461;
}

.lineThrough {
position: relative;
z-index: 1;
display: block;
margin-bottom: 15px;
width: 100%;
color: #757575;
text-align: center;
font-size: 80%;
}

.lineThrough::before {
position: absolute;
top: 50%;
left: 50%;
z-index: -1;
margin-top: -5px;
margin-left: -20px;
width: 40px;
height: 10px;
background-color: #fff;
content: '';
}

.lineThrough::after {
position: absolute;
top: 49%;
z-index: -2;
display: block;
width: 100%;
border-bottom: 1px solid #ddd;
content: '';
}
74 changes: 74 additions & 0 deletions src/components/LoginThirdParty/LoginThirdParty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* eslint-disable css-modules/no-unused-class */
/* eslint-disable css-modules/no-undef-class */
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/

import React from 'react';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import fetch from '../../core/fetch';
import LoginThirdPartyButton from './LoginThirdPartyButton';
import s from '../LoginThirdParty/LoginThirdParty.css';

async function getAuthData() {
const resp = await fetch('/graphql', {
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: '{auth{loginName,buttonClass,buttonText,routeTo,icon}}',
}),
credentials: 'include',
});

const { data } = await resp.json();
if (!data || !data.auth) throw new Error('can\'t load third party auth data');

return data;
}

class LoginThirdParty extends React.Component {
constructor(props) {
super(props);

this.state = {
loginThirdParty: [],
};
}

componentDidMount() {
const stateSetter = this.setState.bind(this);
getAuthData().then((data) => {
stateSetter({
loginThirdParty: data.auth,
});
});
}

render() {
return (
<div>
{this.state.loginThirdParty.map(thirdPartyAuth => (
<LoginThirdPartyButton
className={s.formGroup}
linkClassName={s[thirdPartyAuth.buttonClass]}
iconClassName={s.icon}
thirdPartyAuth={thirdPartyAuth}
key={thirdPartyAuth.loginName}
/>
))}

{ this.state.loginThirdParty.lenght >= 1 ? <strong className={s.lineThrough}>OR</strong> : '' }
</div>
);
}
}

export default withStyles(s)(LoginThirdParty);
50 changes: 50 additions & 0 deletions src/components/LoginThirdParty/LoginThirdPartyButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* eslint-disable css-modules/no-unused-class */
/* eslint-disable css-modules/no-undef-class */
/**
* React Starter Kit (https://www.reactstarterkit.com/)
*
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/

import React, { PropTypes } from 'react';

function LoginThirdPartyButton({
thirdPartyAuth,
linkClassName,
iconClassName,
...props
}) {
return (
<div {...props}>
<a className={linkClassName} href={thirdPartyAuth.routeTo}>
<svg
className={iconClassName}
width="30"
height="30"
viewBox="0 0 30 30"
xmlns="http://www.w3.org/2000/svg"
>
<path d={thirdPartyAuth.icon} />
</svg>
<span>{thirdPartyAuth.buttonText}</span>
</a>
</div>
);
}

LoginThirdPartyButton.propTypes = {
linkClassName: PropTypes.string.isRequired,
iconClassName: PropTypes.string.isRequired,
thirdPartyAuth: PropTypes.shape({
loginName: PropTypes.string,
routeTo: PropTypes.string,
buttonClass: PropTypes.string,
icon: PropTypes.string,
buttonText: PropTypes.string,
}).isRequired,
};

export default LoginThirdPartyButton;
Loading