Skip to content

Commit 7a1072b

Browse files
committed
chore: space to tabs
1 parent 4b5b292 commit 7a1072b

File tree

4 files changed

+69
-74
lines changed

4 files changed

+69
-74
lines changed

gmcserver-server/src/main/java/me/vinceh121/gmcserver/entities/User.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@
1717
*/
1818
package me.vinceh121.gmcserver.entities;
1919

20-
import org.bson.codecs.pojo.annotations.BsonIgnore;
21-
2220
import com.fasterxml.jackson.annotation.JsonIgnore;
23-
2421
import io.vertx.core.json.JsonObject;
2522
import me.vinceh121.gmcserver.mfa.MFAKey;
26-
import org.bson.types.ObjectId;
23+
import org.bson.codecs.pojo.annotations.BsonIgnore;
2724
import xyz.bowser65.tokenize.IAccount;
2825

29-
import java.util.UUID;
30-
3126
/**
3227
* MFA: When setting up MFA, the key will be set, however the boolean mfa will
3328
* be false, once the confirmation password has been sent, it will be true and
@@ -43,9 +38,9 @@ public class User extends AbstractEntity implements IAccount {
4338
private long gmcId;
4439
private boolean admin, mfa, alertEmails;
4540
private MFAKey mfaKey;
46-
private String passwordResetToken;
41+
private String passwordResetToken;
4742

48-
public long getGmcId() {
43+
public long getGmcId() {
4944
return this.gmcId;
5045
}
5146

@@ -155,11 +150,11 @@ public String toString() {
155150
return this.getUsername() + " (" + this.getId().toString() + ")";
156151
}
157152

158-
public void setPasswordResetToken(String passwordResetToken) {
159-
this.passwordResetToken = passwordResetToken;
160-
}
153+
public void setPasswordResetToken(String passwordResetToken) {
154+
this.passwordResetToken = passwordResetToken;
155+
}
161156

162-
public String getPasswordResetToken() {
163-
return passwordResetToken;
164-
}
157+
public String getPasswordResetToken() {
158+
return passwordResetToken;
159+
}
165160
}

gmcserver-server/src/main/java/me/vinceh121/gmcserver/managers/email/EmailManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@
1717
*/
1818
package me.vinceh121.gmcserver.managers.email;
1919

20-
import java.io.IOException;
21-
import java.nio.file.Files;
22-
import java.nio.file.Paths;
23-
import java.util.regex.Matcher;
24-
import java.util.regex.Pattern;
25-
2620
import io.vertx.core.Future;
2721
import io.vertx.core.Promise;
2822
import io.vertx.core.json.JsonObject;
2923
import io.vertx.core.json.pointer.JsonPointer;
3024
import io.vertx.ext.mail.MailClient;
3125
import io.vertx.ext.mail.MailConfig;
3226
import io.vertx.ext.mail.MailMessage;
33-
import me.vinceh121.gmcserver .GMCBuild;
27+
import me.vinceh121.gmcserver.GMCBuild;
3428
import me.vinceh121.gmcserver.GMCServer;
3529
import me.vinceh121.gmcserver.managers.AbstractManager;
3630

31+
import java.io.IOException;
32+
import java.nio.file.Files;
33+
import java.nio.file.Paths;
34+
import java.util.regex.Matcher;
35+
import java.util.regex.Pattern;
36+
3737
public class EmailManager extends AbstractManager {
3838
public static final Pattern VAR_PATTERN = Pattern.compile("\\{\\{[a-zA-Z/-_]+\\}\\}");
3939
private final MailClient client;

gmcserver-server/src/main/java/me/vinceh121/gmcserver/modules/AuthModule.java

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public AuthModule(final GMCServer srv) {
4242
this.captchaEnabled = Boolean.parseBoolean(this.srv.getConfig().getProperty("captcha.enabled"));
4343
this.registerRoute(HttpMethod.POST, "/auth/register", this::handleRegister);
4444
this.registerRoute(HttpMethod.POST, "/auth/login", this::handleLogin);
45-
this.registerRoute(HttpMethod.POST, "/auth/password-reset", this::handlePasswordReset);
45+
this.registerRoute(HttpMethod.POST, "/auth/password-reset", this::handlePasswordReset);
4646
this.registerRoute(HttpMethod.POST, "/auth/password-reset/confirm", this::handlePasswordResetLink);
4747

4848
this.registerAuthedRoute(HttpMethod.POST, "/auth/mfa", this::handleSubmitMfa);
4949
this.registerStrictAuthedRoute(HttpMethod.PUT, "/auth/mfa", this::handleActivateMfa);
50-
this.registerStrictAuthedRoute(HttpMethod.DELETE, "/auth/mfa", this::handleDisableMfa);
50+
this.registerStrictAuthedRoute(HttpMethod.DELETE, "/auth/mfa", this::handleDisableMfa);
5151
}
5252

5353
private void handleRegister(final RoutingContext ctx) {
@@ -97,38 +97,38 @@ private void handleRegister(final RoutingContext ctx) {
9797
final String captchaAnswer = obj.getString("captchaAnswer");
9898
final String captchaId = obj.getString("captchaId");
9999
this.srv.getWebClient()
100-
.postAbs(this.srv.getConfig().getProperty("captcha.url") + "/answer")
101-
.as(BodyCodec.jsonObject())
102-
.sendJsonObject(new JsonObject().put("answer", captchaAnswer).put("id", captchaId))
103-
.onSuccess(res -> {
104-
final String captchaRes = res.body().getString("result");
105-
if ("True".equals(captchaRes)) {
106-
this.handleRegisterLogin(ctx, username, email, password);
107-
} else if ("False".equals(captchaRes)) {
108-
this.error(ctx, 400, "Captcha failed", new JsonObject().put("captchaResponse", captchaRes));
109-
} else if ("Expired".equals(captchaRes)) {
110-
this.error(ctx, 400, "Captcha expired", new JsonObject().put("captchaResponse", captchaRes));
111-
} else {
112-
this.log.error("Received unexpected response from LibreCaptcha: '{}'", captchaRes);
113-
this.error(ctx, 502, "Received unexpected response from LibreCaptcha");
114-
}
115-
})
116-
.onFailure(t -> {
117-
this.log.info("Failed to verify captcha", t);
118-
this.error(ctx, 502, "Failed to verify captcha");
119-
});
100+
.postAbs(this.srv.getConfig().getProperty("captcha.url") + "/answer")
101+
.as(BodyCodec.jsonObject())
102+
.sendJsonObject(new JsonObject().put("answer", captchaAnswer).put("id", captchaId))
103+
.onSuccess(res -> {
104+
final String captchaRes = res.body().getString("result");
105+
if ("True".equals(captchaRes)) {
106+
this.handleRegisterLogin(ctx, username, email, password);
107+
} else if ("False".equals(captchaRes)) {
108+
this.error(ctx, 400, "Captcha failed", new JsonObject().put("captchaResponse", captchaRes));
109+
} else if ("Expired".equals(captchaRes)) {
110+
this.error(ctx, 400, "Captcha expired", new JsonObject().put("captchaResponse", captchaRes));
111+
} else {
112+
this.log.error("Received unexpected response from LibreCaptcha: '{}'", captchaRes);
113+
this.error(ctx, 502, "Received unexpected response from LibreCaptcha");
114+
}
115+
})
116+
.onFailure(t -> {
117+
this.log.info("Failed to verify captcha", t);
118+
this.error(ctx, 502, "Failed to verify captcha");
119+
});
120120
} else {
121121
this.handleRegisterLogin(ctx, username, email, password);
122122
}
123123
}
124124

125125
private void handleRegisterLogin(final RoutingContext ctx, final String username, final String email,
126-
final String password) {
126+
final String password) {
127127
this.srv.getAuthenticator().register(username, email, password).onSuccess(user -> {
128128
final GenerateTokenAction action = this.srv.getUserManager().userLogin().setUser(user);
129129
action.execute().onSuccess(token -> {
130130
ctx.response()
131-
.end(new JsonObject().put("token", token.toString()).put("id", user.getId().toString()).toBuffer());
131+
.end(new JsonObject().put("token", token.toString()).put("id", user.getId().toString()).toBuffer());
132132
}).onFailure(t -> this.error(ctx, 500, "Failed to generate token: " + t.getMessage()));
133133
}).onFailure(t -> {
134134
if (t instanceof IllegalStateException) {
@@ -159,11 +159,11 @@ private void handleLogin(final RoutingContext ctx) {
159159
final GenerateTokenAction action = this.srv.getUserManager().userLogin().setUser(user);
160160
action.execute().onSuccess(token -> {
161161
ctx.response()
162-
// .setStatusCode(user.isMfa() ? 100 : 200)
163-
.end(new JsonObject().put("token", token.toString())
164-
.put("id", user.getId().toString())
165-
.put("mfa", user.isMfa())
166-
.toBuffer());
162+
// .setStatusCode(user.isMfa() ? 100 : 200)
163+
.end(new JsonObject().put("token", token.toString())
164+
.put("id", user.getId().toString())
165+
.put("mfa", user.isMfa())
166+
.toBuffer());
167167
}).onFailure(t -> this.error(ctx, 500, "Failed to generate token: " + t.getMessage()));
168168
}).onFailure(t -> this.errorLogin(ctx, t));
169169
}
@@ -193,7 +193,7 @@ private void handleSubmitMfa(final RoutingContext ctx) {
193193
this.srv.getMfaManager().verifyCode().setPass(pass).setUser(user).execute().onSuccess(res -> {
194194
this.srv.getUserManager().userLogin().setUser(user).setMfaPass(true).execute().onSuccess(token -> {
195195
ctx.response()
196-
.end(new JsonObject().put("token", token.toString()).put("id", user.getId().toString()).toBuffer());
196+
.end(new JsonObject().put("token", token.toString()).put("id", user.getId().toString()).toBuffer());
197197
}).onFailure(t -> this.errorLogin(ctx, t));
198198
}).onFailure(t -> {
199199
if (t instanceof AuthenticationException) {
@@ -225,15 +225,15 @@ private void handleActivateMfa(final RoutingContext ctx) {
225225
return;
226226
}
227227
action.setPass(pass)
228-
.execute()
229-
.onSuccess(res -> ctx.response().end(new JsonObject().toBuffer()))
230-
.onFailure(t -> {
231-
if (t instanceof AuthenticationException) {
232-
this.error(ctx, 403, "Invalid code");
233-
} else {
234-
this.error(ctx, 500, "Failed to confirm MFA setup: " + t.getMessage());
235-
}
236-
});
228+
.execute()
229+
.onSuccess(res -> ctx.response().end(new JsonObject().toBuffer()))
230+
.onFailure(t -> {
231+
if (t instanceof AuthenticationException) {
232+
this.error(ctx, 403, "Invalid code");
233+
} else {
234+
this.error(ctx, 500, "Failed to confirm MFA setup: " + t.getMessage());
235+
}
236+
});
237237
}
238238
}
239239

@@ -254,18 +254,18 @@ private void handleDisableMfa(final RoutingContext ctx) {
254254
}
255255

256256
this.srv.getMfaManager()
257-
.disableMfa()
258-
.setCode(pass)
259-
.setUser(user)
260-
.execute()
261-
.onSuccess(v -> this.error(ctx, 200, "MFA has been disabled"))
262-
.onFailure(t -> {
263-
if (t instanceof AuthenticationException) {
264-
this.error(ctx, 403, "Invaild code");
265-
} else {
266-
this.error(ctx, 500, "Failed to disable MFA: " + t.getMessage());
267-
}
268-
});
257+
.disableMfa()
258+
.setCode(pass)
259+
.setUser(user)
260+
.execute()
261+
.onSuccess(v -> this.error(ctx, 200, "MFA has been disabled"))
262+
.onFailure(t -> {
263+
if (t instanceof AuthenticationException) {
264+
this.error(ctx, 403, "Invaild code");
265+
} else {
266+
this.error(ctx, 500, "Failed to disable MFA: " + t.getMessage());
267+
}
268+
});
269269
}
270270

271271
private void handlePasswordReset(final RoutingContext ctx) {
@@ -303,7 +303,7 @@ private void handlePasswordResetLink(final RoutingContext ctx) {
303303
.find(Filters.eq("passwordResetToken", token))
304304
.first();
305305

306-
if(user == null) {
306+
if (user == null) {
307307
this.error(ctx, 400, "Invalid token");
308308
return;
309309
}

gmcserver-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,5 @@
151151
"react-app"
152152
]
153153
},
154-
"proxy": "http://localhost:8080"
154+
"proxy": "http://gmc.vinceh121.me"
155155
}

0 commit comments

Comments
 (0)