File tree 4 files changed +50
-7
lines changed
4 files changed +50
-7
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,17 @@ const labels = {
17
17
google : 'Login with Google'
18
18
} ;
19
19
20
+ const linkLabels = {
21
+ github : {
22
+ connect : 'Connect GitHub Account' ,
23
+ connected : 'Re-link GitHub Account'
24
+ } ,
25
+ google : {
26
+ connect : 'Connect Google Account' ,
27
+ connected : 'Re-link Google Account'
28
+ }
29
+ } ;
30
+
20
31
const icons = {
21
32
github : GithubIcon ,
22
33
google : GoogleIcon
@@ -31,22 +42,35 @@ const StyledButton = styled(Button)`
31
42
width: ${ remSize ( 300 ) } ;
32
43
` ;
33
44
34
- function SocialAuthButton ( { service } ) {
45
+ function SocialAuthButton ( { service, link , connected } ) {
35
46
const ServiceIcon = icons [ service ] ;
47
+ let label ;
48
+ if ( link ) {
49
+ label = connected ? linkLabels [ service ] . connected : linkLabels [ service ] . connect ;
50
+ } else {
51
+ label = labels [ service ] ;
52
+ }
36
53
return (
37
54
< StyledButton
38
55
iconBefore = { < ServiceIcon aria-label = { `${ service } logo` } /> }
39
56
href = { authUrls [ service ] }
40
57
>
41
- { labels [ service ] }
58
+ { label }
42
59
</ StyledButton >
43
60
) ;
44
61
}
45
62
46
63
SocialAuthButton . services = services ;
47
64
48
65
SocialAuthButton . propTypes = {
49
- service : PropTypes . oneOf ( [ 'github' , 'google' ] ) . isRequired
66
+ service : PropTypes . oneOf ( [ 'github' , 'google' ] ) . isRequired ,
67
+ link : PropTypes . bool ,
68
+ connected : PropTypes . bool
69
+ } ;
70
+
71
+ SocialAuthButton . defaultProps = {
72
+ link : false ,
73
+ connected : false
50
74
} ;
51
75
52
76
export default SocialAuthButton ;
Original file line number Diff line number Diff line change @@ -13,21 +13,37 @@ import APIKeyForm from '../components/APIKeyForm';
13
13
import Nav from '../../../components/Nav' ;
14
14
15
15
function SocialLoginPanel ( props ) {
16
+ const { user } = props ;
16
17
return (
17
18
< React . Fragment >
18
19
< AccountForm { ...props } />
19
20
< h2 className = "form-container__divider" > Social Login</ h2 >
20
21
< p className = "account__social-text" >
21
- Use your GitHub or Google account to log into the p5.js Web Editor.
22
+ Use your GitHub or Google account to login to the p5.js Web Editor.
22
23
</ p >
23
24
< div className = "account__social-stack" >
24
- < SocialAuthButton service = { SocialAuthButton . services . github } />
25
- < SocialAuthButton service = { SocialAuthButton . services . google } />
25
+ < SocialAuthButton
26
+ service = { SocialAuthButton . services . github }
27
+ link
28
+ connected = { ! ! user . github }
29
+ />
30
+ < SocialAuthButton
31
+ service = { SocialAuthButton . services . google }
32
+ link
33
+ connected = { ! ! user . google }
34
+ />
26
35
</ div >
27
36
</ React . Fragment >
28
37
) ;
29
38
}
30
39
40
+ SocialLoginPanel . propTypes = {
41
+ user : PropTypes . shape ( {
42
+ github : PropTypes . string ,
43
+ google : PropTypes . string
44
+ } ) . isRequired
45
+ } ;
46
+
31
47
class AccountView extends React . Component {
32
48
componentDidMount ( ) {
33
49
document . body . className = this . props . theme ;
Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ export function userResponse(user) {
18
18
apiKeys : user . apiKeys ,
19
19
verified : user . verified ,
20
20
id : user . _id ,
21
- totalSize : user . totalSize
21
+ totalSize : user . totalSize ,
22
+ github : user . github ,
23
+ google : user . google
22
24
} ;
23
25
}
24
26
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ const userSchema = new Schema({
50
50
verifiedToken : String ,
51
51
verifiedTokenExpires : Date ,
52
52
github : { type : String } ,
53
+ google : { type : String } ,
53
54
email : { type : String , unique : true } ,
54
55
tokens : Array ,
55
56
apiKeys : { type : [ apiKeySchema ] } ,
You can’t perform that action at this time.
0 commit comments