Commits

Christian Specht  committed 16ebe57

throw exception if the password is wrong
(fixes #5)

  • Participants
  • Parent commits b9ff256

Comments (0)

Files changed (4)

File src/BitbucketBackup/Program.cs

                 }
 
                 var json = JObject.Parse(response);
+
+                // If the authentication fails, the BB API returns only a subset of the repository information.
+                // One of the missing things is the "has_wiki" property. So if it's missing, the password is probably wrong
+                if (json.SelectToken("repositories[0].has_wiki") == null)
+                {                    
+                    throw new ClientException(Resources.AuthenticationFailed, null);
+                }
+
                 var repos =
                     from r in json["repositories"].Children()
                     select new { RepoName = (string)r["slug"], HasWiki = (bool)r["has_wiki"] };

File src/BitbucketBackup/Resources.Designer.cs

         }
         
         /// <summary>
+        ///   Sucht eine lokalisierte Zeichenfolge, die Authentication failed.
+        ///Please check if the password is valid! ähnelt.
+        /// </summary>
+        internal static string AuthenticationFailed {
+            get {
+                return ResourceManager.GetString("AuthenticationFailed", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Sucht eine lokalisierte Zeichenfolge, die Backup completed! ähnelt.
         /// </summary>
         internal static string BackupCompleted {

File src/BitbucketBackup/Resources.de.resx

   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <data name="AuthenticationFailed" xml:space="preserve">
+    <value>Die Authentifizierung ist fehlgeschlagen.
+Bitte überprüfen Sie das Passwort!</value>
+  </data>
   <data name="BackupCompleted" xml:space="preserve">
     <value>Backup wurde abgeschlossen!</value>
   </data>

File src/BitbucketBackup/Resources.resx

   <data name="PressEnter" xml:space="preserve">
     <value>Press &lt;ENTER&gt; to quit!</value>
   </data>
+  <data name="AuthenticationFailed" xml:space="preserve">
+    <value>Authentication failed.
+Please check if the password is valid!</value>
+  </data>
 </root>