- comments
authorJan Kupec <jkupec@suse.cz>
Fri, 26 Sep 2008 14:21:00 +0000 (14:21 +0000)
committerJan Kupec <jkupec@suse.cz>
Fri, 26 Sep 2008 14:21:00 +0000 (14:21 +0000)
- fixed setUserName() name to be consistent with getter

package/libzypp.changes
zypp/media/CredentialManager.h
zypp/media/MediaCurl.cc
zypp/media/MediaUserAuth.h

index bc366e5..2b12297 100644 (file)
@@ -8,6 +8,12 @@ Fri Sep 26 15:37:50 CEST 2008 - ma@suse.de
 - version 5.13.0 (13)
 
 -------------------------------------------------------------------
+Fri Sep 26 15:25:33 CEST 2008 - jkupec@suse.cz
+
+- save user credentials after asking for them
+- revision 11181
+
+-------------------------------------------------------------------
 Thu Sep 25 23:19:55 CEST 2008 - jkupec@suse.cz
 
 - ZConfig::credentialsGlobal{File,Dir}() added
index 12ff096..62d4830 100644 (file)
@@ -111,6 +111,17 @@ namespace zypp
 
     /**
      * Add new credentials with user callbacks.
+     * 
+     * If the cred->url() contains 'credentials' query parameter, the
+     * credentials will be automatically saved to the specified file using the
+     * \ref saveInFile() method.
+     *
+     * Otherwise a callback will be called asking whether to save to custom
+     * file, or to global or user's credentials catalog. 
+     *
+     * \todo Currently no callback is called, credentials are automatically
+     *       saved to user's credentials.cat if no 'credentials' parameter
+     *       has been specified
      */
     void addCred(const AuthData & cred);
 
index d0ca341..b96607a 100644 (file)
@@ -1605,10 +1605,10 @@ bool MediaCurl::authenticate(const string & availAuthTypes, bool firstTry) const
 
     // preset the username if present in current url
     if (!_url.getUsername().empty() && firstTry)
-      curlcred->setUserName(_url.getUsername());
+      curlcred->setUsername(_url.getUsername());
 
     string prompt_msg;
-    if (!firstTry || !_url.getUsername().empty())
+    if (!firstTry)
       prompt_msg = _("Invalid user name or password.");
     else // first prompt
       prompt_msg = boost::str(boost::format(
@@ -1625,7 +1625,18 @@ bool MediaCurl::authenticate(const string & availAuthTypes, bool firstTry) const
           << "CurlAuthData: " << *curlcred << endl;
 
       if (curlcred->valid())
+      {
         credentials = curlcred;
+          // if (credentials->username() != _url.getUsername())
+          //   _url.setUsername(credentials->username());
+          /**
+           *  \todo find a way to save the url with changed username
+           *  back to repoinfo or dont store urls with username
+           *  (and either forbid more repos with the same url and different
+           *  user, or return a set of credentials from CM and try them one
+           *  by one) 
+           */
+      }
     }
     else
     {
index d27f8fa..252e591 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <curl/curl.h>
 
+#include "zypp/base/Deprecated.h"
+
 #include "zypp/Url.h"
 #include "zypp/base/PtrTypes.h"
 
@@ -49,7 +51,9 @@ public:
   virtual bool valid() const;
 
   void setUrl(const Url & url) { _url = url; }
-  void setUserName(const std::string & username) { _username = username; }
+  void setUsername(const std::string & username) { _username = username; }
+  /** \deprecated use setUsername() instead */
+  ZYPP_DEPRECATED void setUserName(const std::string & username) { _username = username; }
   void setPassword(const std::string & password) { _password = password; }  
 
   Url url() const { return _url; }