use of se.light.assembly64.model.HttpException in project assembly64fx by freabemania.
the class UserService method storeSettings.
public void storeSettings() throws HttpException {
Response response = null;
try {
response = getClient().target(getBackendServer()).path("/leet/user3/settings").request().header("email", getSessionInfo().getEmail()).header("token", getSessionInfo().getToken()).post(Entity.json(settings));
} finally {
response.close();
}
invalidateUserDb();
if (response.getStatus() != 200) {
throw new HttpException(response.getStatus());
}
}
use of se.light.assembly64.model.HttpException in project assembly64fx by freabemania.
the class ForgottenPasswordController method register.
@FXML
protected void register() {
if (globalRepoService.contains(CONFMAILSENT)) {
getStage().close();
return;
}
String mail = email.getText();
if (!mail.contains("@")) {
message.setText("Enter valid mail");
return;
}
try {
Analytics.sendEvent("application", "forgotten_pass");
userService.forgotPassword(mail);
globalRepoService.put(CONFMAILSENT, "true");
message.setText("Check your mailbox for confirmation mail");
sendPass.setImage(new Image(getClass().getResourceAsStream("button-close.png")));
} catch (HttpException e) {
message.setText("Error" + e.getErrorCode() + ", please try again");
}
}
use of se.light.assembly64.model.HttpException in project assembly64fx by freabemania.
the class RegistrationController method register.
@FXML
protected void register() {
if (globalRepoService.contains(CONFMAILSENT)) {
getStage().close();
return;
}
String mail = email.getText();
String pass1 = password.getText();
String pass2 = passwordConfirm.getText();
if (!mail.contains("@")) {
message.setText("Enter valid mail");
return;
}
if (pass1.length() < 6) {
message.setText("Password needs to be atleast 6 chars");
return;
}
if (!pass1.equals(pass2)) {
message.setText("Passwords are not matching");
return;
}
try {
userService.register(mail, pass1);
globalRepoService.put(CONFMAILSENT, "true");
message.setText("Check mailbox for confirmation");
register.setImage(new Image(getClass().getResourceAsStream("button-close.png")));
cancel.setVisible(false);
} catch (HttpException e) {
switch(e.getErrorCode()) {
case 428:
message.setText("Registration is closed, please try later");
break;
default:
message.setText("Unable to register");
}
// action.setText("Close");
}
}
use of se.light.assembly64.model.HttpException in project assembly64fx by freabemania.
the class SettingsController method storeSettings.
@FXML
protected void storeSettings(MouseEvent event) {
try {
Settings settings = userService.getSettings();
if (settings.getNotificationOnNewContent() != notifyOnNewContent.isSelected() || !settings.getCountry().equals(countries.getSelectionModel().getSelectedItem()) || !settings.getName().equals(username.getText()) || !settings.getAnonymous().equals(anonymous.isSelected())) {
settings.setNotificationOnNewContent(notifyOnNewContent.isSelected());
settings.setCountry(countries.getSelectionModel().getSelectedItem());
settings.setName(username.getText());
settings.setAnonymous(anonymous.isSelected());
userService.storeSettings();
Analytics.sendEvent("application_click", "store_settings");
LOGGER.info("Settings were stored");
}
localDb.setSidifyAsDefault(sidifyAsDefault.isSelected());
if (userService.isPremium()) {
int tmp = workers.getSelectionModel().getSelectedIndex();
if (tmp != initialWorkers) {
localDb.addLocalDBSetting("instances", String.valueOf(workers.getSelectionModel().getSelectedIndex()));
Scheduler.reinitIfNotWorking();
}
localDb.addLocalDBSetting("vicepath", vicePath.getText());
localDb.setRunScriptInsteadOfVice(executeAsCommand.isSelected());
if (executeAsCommand.isSelected()) {
localDb.setViceStyleFormatOnArgs(viceStyleFormatOnArgs.isSelected());
} else {
localDb.setViceStyleFormatOnArgs(false);
}
}
localDb.addLocalDBSetting("maxage", String.valueOf(latestMaxAge.getSelectionModel().getSelectedItem()));
if (latestMaxAge.getSelectionModel().getSelectedIndex() > currMaxAgeIndex) {
for (WorkLocation location : userService.getExistingLocations()) {
FileUtils.deleteQuietly(new File(location.asFile().getAbsolutePath() + "/.db/latest"));
}
}
getStage().close();
} catch (Exception e) {
if (e instanceof HttpException) {
GenericMessageDialogController.withErrorProps("Oops", "Unable to store. Invalid length of name").showAndWait();
}
LOGGER.error("Unable to store settings", e);
}
}
use of se.light.assembly64.model.HttpException in project assembly64fx by freabemania.
the class UserService method loginToken.
public String loginToken(String email, String token) throws HttpException {
Response response = getClient().target(getBackendServer()).path("/leet/user3/tokenlogin/" + email + "/" + encrypt(token)).request().get();
if (response.getStatus() != 200) {
response.close();
throw new HttpException(response.getStatus());
}
userLite = response.readEntity(UserLite.class);
return userLite.getToken();
}
Aggregations