Skip to content
This repository was archived by the owner on Mar 10, 2019. It is now read-only.

Commit b41dff3

Browse files
committed
Handling disabled register with email
1 parent 9e7593f commit b41dff3

3 files changed

Lines changed: 32 additions & 12 deletions

File tree

WebContent/index.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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');
@@ -380,6 +380,7 @@ class LoginManager {
380380
* @param {string} data.aC.fb - Facebook app id
381381
* @param {string} data.aC.gh - Github app id
382382
* @param {string} data.aC.tw - Twitter app id
383+
* @param {string} data.aC.pw - Verification email sender
383384
*/
384385
data.css.sort(function (a, b) {
385386
return a.w - b.w;
@@ -396,12 +397,21 @@ class LoginManager {
396397
}
397398
} else {
398399
const authConfig = data.aC;
400+
Notifier.debug(authConfig);
401+
402+
399403
this.setupGoogle(authConfig.g);
400404
this.setupFacebook(authConfig.fb);
401405
this.setupGitHub(authConfig.gh);
402406
this.setupTwitter(authConfig.tw);
403407

404-
Notifier.debug(authConfig);
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+
}
405415

406416
switch (getURLParameter("aT")) {
407417
case "gh":

src/main/java/com/gianlu/pyxreloaded/handlers/FirstLoadHandler.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.gianlu.pyxreloaded.game.GameOptions;
88
import com.gianlu.pyxreloaded.server.Annotations;
99
import com.gianlu.pyxreloaded.server.Parameters;
10+
import com.gianlu.pyxreloaded.singletons.Emails;
1011
import com.gianlu.pyxreloaded.singletons.LoadedCards;
1112
import com.gianlu.pyxreloaded.singletons.Preferences;
1213
import com.gianlu.pyxreloaded.singletons.SocialLogin;
@@ -18,11 +19,16 @@
1819
public class FirstLoadHandler extends BaseHandler {
1920
public static final String OP = Consts.Operation.FIRST_LOAD.toString();
2021
private final LoadedCards loadedCards;
22+
private final Emails emails;
2123
private final SocialLogin socials;
2224
private final Preferences preferences;
2325

24-
public FirstLoadHandler(@Annotations.LoadedCards LoadedCards loadedCards, @Annotations.SocialLogin SocialLogin socials, @Annotations.Preferences Preferences preferences) {
26+
public FirstLoadHandler(@Annotations.LoadedCards LoadedCards loadedCards,
27+
@Annotations.Emails Emails emails,
28+
@Annotations.SocialLogin SocialLogin socials,
29+
@Annotations.Preferences Preferences preferences) {
2530
this.loadedCards = loadedCards;
31+
this.emails = emails;
2632
this.socials = socials;
2733
this.preferences = preferences;
2834
}
@@ -48,14 +54,13 @@ public JsonWrapper handle(User user, Parameters params, HttpServerExchange excha
4854
}
4955
}
5056

51-
// TODO: Is password login enabled?
52-
53-
JsonWrapper socialsConfig = new JsonWrapper();
54-
if (socials.googleEnabled()) socialsConfig.add(Consts.AuthType.GOOGLE, socials.googleAppId());
55-
if (socials.facebookEnabled()) socialsConfig.add(Consts.AuthType.FACEBOOK, socials.facebookAppId());
56-
if (socials.githubEnabled()) socialsConfig.add(Consts.AuthType.GITHUB, socials.githubAppId());
57-
if (socials.twitterEnabled()) socialsConfig.add(Consts.AuthType.TWITTER, socials.twitterAppId());
58-
obj.add(Consts.GeneralKeys.AUTH_CONFIG, socialsConfig);
57+
JsonWrapper authConfig = new JsonWrapper();
58+
if (emails.enabled()) authConfig.add(Consts.AuthType.PASSWORD, emails.senderEmail());
59+
if (socials.googleEnabled()) authConfig.add(Consts.AuthType.GOOGLE, socials.googleAppId());
60+
if (socials.facebookEnabled()) authConfig.add(Consts.AuthType.FACEBOOK, socials.facebookAppId());
61+
if (socials.githubEnabled()) authConfig.add(Consts.AuthType.GITHUB, socials.githubAppId());
62+
if (socials.twitterEnabled()) authConfig.add(Consts.AuthType.TWITTER, socials.twitterAppId());
63+
obj.add(Consts.GeneralKeys.AUTH_CONFIG, authConfig);
5964

6065
Set<PyxCardSet> cardSets = loadedCards.getLoadedSets();
6166
JsonArray json = new JsonArray(cardSets.size());

src/main/java/com/gianlu/pyxreloaded/singletons/Emails.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public Emails(ServerDatabase db, Preferences preferences, UsersWithAccount accou
4747
}
4848
}
4949

50+
@NotNull
51+
public String senderEmail() {
52+
return senderEmail;
53+
}
54+
5055
@Nullable
5156
private Mailer mailer(Preferences preferences) {
5257
if (senderEmail == null || senderEmail.isEmpty()) return null;

0 commit comments

Comments
 (0)