Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a /Myth/ChangePassword service to the backend.

Since we now have basic authentication working for the backend
webserver, add a service which we can use to change that password.
Setup page code will be in my next commit.

NOTE: This does modify the binary API version, so make clean, etc..
  • Loading branch information...
commit 3b2fbddcdcdd12cc7664552cd1999dfe2f79f06b 1 parent effc903
Chris Pinkham cpinkham authored
2  mythtv/libs/libmythbase/mythversion.h
View
@@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
-#define MYTH_BINARY_VERSION "0.25.20110324-1"
+#define MYTH_BINARY_VERSION "0.25.20110326-1"
/** \brief Increment this whenever the MythTV network protocol changes.
*
4 mythtv/libs/libmythservicecontracts/services/mythServices.h
View
@@ -54,6 +54,7 @@ class SERVICE_PUBLIC MythServices : public Service //, public QScriptable ???
Q_CLASSINFO( "PutSetting_Method", "POST" )
Q_CLASSINFO( "AddStorageGroupDir_Method", "POST" )
Q_CLASSINFO( "RemoveStorageGroupDir_Method", "POST" )
+ Q_CLASSINFO( "ChangePassword_Method", "POST" )
public:
@@ -94,6 +95,9 @@ class SERVICE_PUBLIC MythServices : public Service //, public QScriptable ???
const QString &Key,
const QString &Value ) = 0;
+ virtual bool ChangePassword ( const QString &UserName,
+ const QString &OldPassword,
+ const QString &NewPassword ) = 0;
};
#endif
45 mythtv/programs/mythbackend/services/myth.cpp
View
@@ -469,3 +469,48 @@ bool Myth::PutSetting( const QString &sHostName,
throw ( QString( "Key Required" ));
}
+/////////////////////////////////////////////////////////////////////////////
+//
+/////////////////////////////////////////////////////////////////////////////
+
+bool Myth::ChangePassword( const QString &sUserName,
+ const QString &sOldPassword,
+ const QString &sNewPassword )
+{
+ bool bResult = false;
+
+ if (sUserName.isEmpty())
+ {
+ throw ( QString( "UserName not supplied when trying to change "
+ "password." ) );
+ }
+
+ if (sOldPassword.isEmpty())
+ {
+ throw ( QString( "Old Password not supplied when trying to change "
+ "password for '%1'." ).arg(sUserName) );
+ }
+
+ if (sNewPassword.isEmpty())
+ {
+ throw ( QString( "New Password not supplied when trying to change "
+ "password for '%1'." ).arg(sUserName) );
+ }
+
+ if (sOldPassword !=
+ gCoreContext->GetSetting( "HTTP/Protected/Password", ""))
+ {
+ throw ( QString( "Incorrect Old Password supplied when trying to "
+ "change password for '%1'." ).arg(sUserName) );
+ }
+
+ if (gCoreContext->SaveSettingOnHost( "HTTP/Protected/Password", sNewPassword,
+ QString() ) )
+ {
+ gCoreContext->ClearSettingsCache();
+ bResult = true;
+ }
+
+ return bResult;
+}
+
4 mythtv/programs/mythbackend/services/myth.h
View
@@ -60,6 +60,10 @@ class Myth : public MythServices
bool PutSetting ( const QString &HostName,
const QString &Key,
const QString &Value );
+
+ bool ChangePassword ( const QString &UserName,
+ const QString &OldPassword,
+ const QString &NewPassword );
};
// --------------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.