@@ -58,8 +58,8 @@ class LoginManager {
5858
5959 this . pyxEmail = this . _pyx . find ( 'input[type=email]' ) ;
6060
61- this . pyxSubmit = this . _pyx . find ( '._register' ) ;
62- this . pyxSubmit . on ( 'click' , ( ) => this . createPyxAccount ( ) ) ;
61+ this . pyxRegister = this . _pyx . find ( '._register' ) ;
62+ this . pyxRegister . on ( 'click' , ( ) => this . createPyxAccount ( ) ) ;
6363
6464 this . _socials = $ ( '#socialLogin' ) ;
6565 this . googleSignIn = this . _socials . find ( '#googleSignIn' ) ;
@@ -148,47 +148,67 @@ class LoginManager {
148148 } )
149149 }
150150
151- setupGoogle ( ) {
152- gapi . load ( 'auth2' , ( ) => {
153- this . google_auth2 = gapi . auth2 . init ( {
154- client_id : '464424051073-loi5kmcc3qev5a1lr5hvrjiqb3kcu2cl.apps.googleusercontent.com' ,
155- cookiepolicy : 'single_host_origin' ,
156- } ) ;
151+ setupGoogle ( appId ) {
152+ if ( appId === undefined ) {
153+ this . googleSignIn . hide ( ) ;
154+ } else {
155+ this . googleSignIn . show ( ) ;
156+ gapi . load ( 'auth2' , ( ) => {
157+ this . google_auth2 = gapi . auth2 . init ( {
158+ client_id : appId ,
159+ cookiepolicy : 'single_host_origin' ,
160+ } ) ;
157161
158- this . google_auth2 . attachClickHandler ( this . googleSignIn [ 0 ] , { } ,
159- ( user ) => this . _googleSuccess ( user ) ,
160- ( error ) => Notifier . error ( "Failed signing in with Google." , error ) ) ;
161- } ) ;
162+ this . google_auth2 . attachClickHandler ( this . googleSignIn [ 0 ] , { } ,
163+ ( user ) => this . _googleSuccess ( user ) ,
164+ ( error ) => Notifier . error ( "Failed signing in with Google." , error ) ) ;
165+ } ) ;
166+ }
162167 }
163168
164- setupFacebook ( ) {
165- FB . init ( {
166- appId : '198497240899387' ,
167- cookie : true ,
168- xfbml : true ,
169- autoLogAppEvents : Notifier . _debug ,
170- version : 'v2.12'
171- } ) ;
169+ setupFacebook ( appId ) {
170+ if ( appId === undefined ) {
171+ this . facebookSignIn . hide ( ) ;
172+ } else {
173+ FB . init ( {
174+ appId : appId ,
175+ cookie : true ,
176+ xfbml : true ,
177+ autoLogAppEvents : Notifier . _debug ,
178+ version : 'v2.12'
179+ } ) ;
172180
173- FB . AppEvents . logPageView ( ) ;
181+ FB . AppEvents . logPageView ( ) ;
174182
175- this . facebookSignIn . on ( 'click' , ( ) => FB . login ( ( user ) => {
176- this . _facebookSuccess ( user ) ;
177- } , {
178- scope : 'email,public_profile' ,
179- } ) ) ;
183+ this . facebookSignIn . show ( ) ;
184+ this . facebookSignIn . on ( 'click' , ( ) => FB . login ( ( user ) => {
185+ this . _facebookSuccess ( user ) ;
186+ } , {
187+ scope : 'email,public_profile' ,
188+ } ) ) ;
189+ }
180190 }
181191
182- setupGitHub ( ) {
183- this . githubSignIn . on ( 'click' , ( ) => {
184- window . location = "https://github.com/login/oauth/authorize?scope=read:user,user:email&client_id=d7057c607cf69f592239"
185- } )
192+ setupGitHub ( appId ) {
193+ if ( appId === undefined ) {
194+ this . githubSignIn . hide ( ) ;
195+ } else {
196+ this . githubSignIn . show ( ) ;
197+ this . githubSignIn . on ( 'click' , ( ) => {
198+ window . location = "https://github.com/login/oauth/authorize?scope=read:user,user:email&client_id=" + appId
199+ } )
200+ }
186201 }
187202
188- setupTwitter ( ) {
189- this . twitterSignIn . on ( 'click' , ( ) => {
190- window . location = "/TwitterStartAuthFlow"
191- } )
203+ setupTwitter ( appId ) {
204+ if ( appId === undefined ) {
205+ this . twitterSignIn . hide ( ) ;
206+ } else {
207+ this . twitterSignIn . show ( ) ;
208+ this . twitterSignIn . on ( 'click' , ( ) => {
209+ window . location = "/TwitterStartAuthFlow"
210+ } )
211+ }
192212 }
193213
194214 _showNickDialog ( params , success ) {
@@ -354,6 +374,14 @@ class LoginManager {
354374
355375 setup ( ) {
356376 Requester . request ( "fl" , { } , ( data ) => {
377+ /**
378+ * @param {object } data.aC - Auth config
379+ * @param {string } data.aC.g - Google app id
380+ * @param {string } data.aC.fb - Facebook app id
381+ * @param {string } data.aC.gh - Github app id
382+ * @param {string } data.aC.tw - Twitter app id
383+ * @param {string } data.aC.pw - Verification email sender
384+ */
357385 data . css . sort ( function ( a , b ) {
358386 return a . w - b . w ;
359387 } ) ;
@@ -368,10 +396,22 @@ class LoginManager {
368396 window . location = "/games/" ;
369397 }
370398 } else {
371- this . setupGoogle ( ) ;
372- this . setupFacebook ( ) ;
373- this . setupGitHub ( ) ;
374- this . setupTwitter ( ) ;
399+ const authConfig = data . aC ;
400+ Notifier . debug ( authConfig ) ;
401+
402+
403+ this . setupGoogle ( authConfig . g ) ;
404+ this . setupFacebook ( authConfig . fb ) ;
405+ this . setupGitHub ( authConfig . gh ) ;
406+ this . setupTwitter ( authConfig . tw ) ;
407+
408+ if ( "pw" in authConfig ) {
409+ this . pyxEmail . parent ( ) . show ( ) ;
410+ this . pyxRegister . show ( ) ;
411+ } else {
412+ this . pyxEmail . parent ( ) . hide ( ) ;
413+ this . pyxRegister . hide ( ) ;
414+ }
375415
376416 switch ( getURLParameter ( "aT" ) ) {
377417 case "gh" :
0 commit comments