Fix stepic credentials saving: save only non-empty, non-default values
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Fri, 29 Jul 2016 09:17:08 +0000 (12:17 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Fri, 29 Jul 2016 09:17:44 +0000 (12:17 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/stepic/StepicStudyOptions.java

index f7751f1f01db12c0c8f2dd5511af3e4acc69ddcc..a0d4e70aa74dd4caef1cff35c428b6c26f5e354d 100644 (file)
@@ -107,7 +107,8 @@ public class StepicStudyOptions implements StudyOptionsProvider {
 
   @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) {
@@ -142,11 +143,12 @@ public class StepicStudyOptions implements StudyOptionsProvider {
       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 {