Skip to content

Commit

Permalink
Fix stepic credentials saving: save only non-empty, non-default values
Browse files Browse the repository at this point in the history
  • Loading branch information
evgraph committed Jul 29, 2016
1 parent 459b771 commit ac4ef4e
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public void setLogin(@Nullable final String login) {

@NotNull
private String getPassword() {
return String.valueOf(myPasswordField.getPassword());
final String passwordText = String.valueOf(myPasswordField.getPassword());
return passwordText.equals(DEFAULT_PASSWORD_TEXT) ? "" : passwordText;
}

private void setPassword(@NotNull final String password) {
Expand Down Expand Up @@ -142,11 +143,12 @@ public void apply() {
if (project != null) {
StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
taskManager.setEnableTestingFromSamples(myEnableTestingFromSamples.isSelected());
final StepicUser user = taskManager.getUser();
user.setEmail(getLogin());
user.setPassword(getPassword());
if (!StringUtil.isEmptyOrSpaces(getLogin()) && !StringUtil.isEmptyOrSpaces(getPassword())) {
EduStepicConnector.login(getLogin(), getPassword());
final String login = getLogin();
final String password = getPassword();
if (!StringUtil.isEmptyOrSpaces(login) && !StringUtil.isEmptyOrSpaces(password)) {
final StepicUser user = taskManager.getUser();
user.setEmail(login);
user.setPassword(password);
}
}
else {
Expand Down

0 comments on commit ac4ef4e

Please sign in to comment.