Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Console: Handle authentication and authenticated requests
- Loading branch information
1 parent
7ee9bdf
commit 900af20
Showing
20 changed files
with
501 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ build | |
.DS_Store | ||
.env | ||
npm-debug.log | ||
|
||
#config | ||
src/config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Automattic, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import './style.css'; | ||
|
||
import { isReady, isLoggedin, getUser } from '../../state/security/selectors'; | ||
import { login, logout } from '../../state/security/actions'; | ||
|
||
const UserMenu = ({ isReady, isLoggedin, login, logout, user }) => { | ||
if (! isReady) { | ||
return ( | ||
<div className="user-menu loading"> | ||
<div className="throbber"></div> | ||
</div> | ||
); | ||
} | ||
|
||
if (!isLoggedin) { | ||
|
||
return ( | ||
<div className="user-menu" onClick={ login }> | ||
<span className="label"></span> | ||
<span className="extra">Sign In</span> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="user-menu authorized" onClick={ logout }> | ||
<span className="label"></span> | ||
<span className="extra">Sign Out</span> | ||
<span className="img"> | ||
<img alt="Avatar" src={ user.avatar_URL } /> | ||
</span> | ||
</div> | ||
); | ||
} | ||
|
||
export default connect( | ||
state => { | ||
return { | ||
isReady: isReady(state), | ||
isLoggedin: isLoggedin(state), | ||
user: getUser(state) | ||
}; | ||
}, | ||
{ login, logout } | ||
)(UserMenu); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
.user-menu { | ||
position: relative; | ||
padding: 10px 0; | ||
font-size: 14px; | ||
color: hsl(201,60%,100%); | ||
background-color: hsl(202,68%,44%); | ||
cursor: pointer; | ||
flex-shrink: 0; | ||
flex-direction: row; | ||
flex-wrap: nowrap; | ||
justify-content: flex-start; | ||
align-items: center; | ||
} | ||
|
||
.user-menu .label, .user-menu .extra { | ||
vertical-align: middle; | ||
line-height: 24px; | ||
color: #FFF; | ||
} | ||
|
||
|
||
.user-menu:active, .user-menu.active { | ||
color: hsl(201,60%,70%); | ||
background-color: hsl(201,60%,100%); | ||
} | ||
|
||
.user-menu:hover, .user-menu:focus { | ||
outline: none; | ||
background-color: hsl(201,60%,70%); | ||
color: #FFF; | ||
} | ||
|
||
.user-menu .label::before { | ||
font-family: Genericons, Noticons; | ||
display: inline-block; | ||
position: relative; | ||
content: '\f427'; | ||
font-size: 24px; | ||
vertical-align: -6px; | ||
text-align: center; | ||
left: 0px; | ||
padding: 0; | ||
width: 44px; | ||
} | ||
|
||
.user-menu .img { | ||
display: block; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
background: transparent; | ||
} | ||
|
||
.user-menu .img img { | ||
display: block; | ||
width: 44px; | ||
height: 44px; | ||
opacity: 0; | ||
transition: opacity 200ms 200ms; | ||
-webkit-transition: opacity 200ms 200ms; | ||
-moz-transition: opacity 200ms 200ms; | ||
} | ||
|
||
.user-menu.authorized .label::before { | ||
content: '\f470'; | ||
left: 0; | ||
width: 44px; | ||
} | ||
|
||
.user-menu.authorized .extra { | ||
position: relative; | ||
left: -3px; | ||
} | ||
|
||
.user-menu.loading { | ||
min-width: 88px; | ||
justify-content: center; | ||
cursor: default; | ||
} | ||
|
||
.user-menu.loading:hover, .user-menu.loading:focus { | ||
outline: none; | ||
background-color: hsl(201,60%,60%); | ||
} | ||
|
||
.user-menu .extra { | ||
display: inline-block; | ||
width: 0; | ||
overflow: hidden; | ||
transition: 200ms 100ms; | ||
opacity: 0; | ||
white-space: nowrap; | ||
} | ||
|
||
.user-menu:hover .extra, .user-menu:focus .extra { | ||
opacity: 1; | ||
width: 64px; | ||
} | ||
|
||
.user-menu.authorized:hover .extra, .user-menu.authorized:focus .extra { | ||
opacity: 1; | ||
width: 110px; | ||
} | ||
|
||
.user-menu:hover img, .user-menu:focus img { | ||
opacity: 0.9; | ||
} | ||
|
||
.throbber { | ||
padding: 0 18px; | ||
display: inline-block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"client_id": "12345", | ||
"redirect_uri": "http://example.com/path/to/app" | ||
} |
Binary file not shown.
Oops, something went wrong.