@@ -7,6 +7,54 @@ import Button from '@material-ui/core/Button'
77import LogoUpload from './LogoUpload'
88import MediaQueryComponent from '../components/MediaQueryComponent'
99
10+ function Error ( { message, callbackUrl} ) {
11+ console . log ( message , callbackUrl )
12+ if ( message ) {
13+ let description = message
14+ if ( message . match ( / C o u l d n o t a u t h e n t i c a t e / ) ) {
15+ description = (
16+ < div >
17+ < p > Eek, it looks like you have an error with your keys!</ p >
18+ < p >
19+ Please make sure you are copying and pasting the
20+ < em > API key</ em > and < em > API key secret</ em > correctly
21+ from the Twitter Developer Dashboard.
22+ </ p >
23+ </ div >
24+ )
25+ } else if ( message . match ( / D e s k t o p a p p l i c a t i o n s / ) ) {
26+ description = (
27+ < div >
28+ < p > Whoops, it looks like 3-Legged oAuth is not enabled.</ p >
29+ < p >
30+ Please go to your app page
31+ at < a href = "https://developer.twitter.com" > developer.twitter.com</ a > and
32+ edit your < em > Authentication Settings</ em > to enable it.
33+ </ p >
34+ </ div >
35+ )
36+ } else if ( message . match ( / C a l l b a c k U R L / ) ) {
37+ description = (
38+ < div >
39+ < p > Sorry, it looks like the < em > Callback URL</ em > has not been set correctly.</ p >
40+ < p > Please go to your app page
41+ at < a href = "https://developer.twitter.com" > developer.twitter.com</ a > and
42+ add < em > { callbackUrl } </ em > to the < em > Callback URLs</ em > in
43+ the < em > Authentication settings</ em > section.
44+ </ p >
45+ </ div >
46+ )
47+ }
48+ return (
49+ < div className = { style . Error } >
50+ { description }
51+ </ div >
52+ )
53+ } else {
54+ return ''
55+ }
56+ }
57+
1058export default class Settings extends MediaQueryComponent {
1159
1260 componentWillMount ( ) {
@@ -20,26 +68,33 @@ export default class Settings extends MediaQueryComponent {
2068
2169 render ( ) {
2270
23- // if there isn't a user provide a welcome message to the first user
24- // who is presumed to be the admin.
71+ // If there isn't a user provide a welcome message to the first user
72+ // who is presumed to be the admin. When the key handshake with Twitter
73+ // fails the user will be redirected to /settings/ with the error query
74+ // parameter set to the message.
2575
2676 let welcome = ''
2777 if ( ! this . props . userLoggedIn ) {
78+ const q = new URLSearchParams ( window . location . search )
79+ const callbackUrl = 'https://demo.docnow.dev/auth/twitter/callback'
80+ const error = < Error message = { q . get ( 'error' ) } callbackUrl = { callbackUrl } />
81+
2882 welcome = (
2983 < div className = { style . Welcome } >
30- < br />
3184 < b > Welcome!</ b >
3285 < p >
33- To setup DocNow, you will need to create a
34- < em > Twitter application</ em > and configure DocNow to use
35- your < em > Consumer Key</ em > and < em > Consumer Secret</ em > keys
36- from Twitter.
37- </ p >
38- < p >
39- Please visit < a href = "https://apps.twitter.com" > apps.twitter.com</ a > to
40- to create your application, and let us know if you
41- have any difficulties at info@docnow.io.
86+ To setup DocNow, you will need to visit the
87+ < a href = "https://developer.twitter.com" > Twitter Developer Portal</ a > and
88+ create a < em > Twitter application</ em > . This is required because you will
89+ need to enter your < em > Application key</ em > and
90+ < em > Application key secret</ em > below.
4291 </ p >
92+ < ol >
93+ < li > Set your < em > Description</ em > to something that describes your DocNow instance for users who are logging in.</ li >
94+ < li > In < em > Authentication Settings</ em > please make sure that < em > 3-Legged oAuth</ em > is enabled.</ li >
95+ < li > Set a callback URL of < em > { callbackUrl } </ em > </ li >
96+ </ ol >
97+ { error }
4398 </ div >
4499 )
45100 }
0 commit comments