X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.h;h=9971278ca45c3fd5e1611c63f2c388c8f4921e90;hp=f63a32b450902d1034b40783e2804c72cc86790b;hb=e0f5fdf1fe6131d403fcaeaa0952e1042590e3e1;hpb=61aac1868f15babb7086d8bc6bbcff530346f438 diff --git a/src/core/core.h b/src/core/core.h index f63a32b4..9971278c 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -85,6 +85,27 @@ public: return instance()->_authenticator->validateUser(userName, password); } + //! Add a new user, exposed so auth providers can call this without being the storage. + /** + * \param userName The user's login name + * \param password The user's uncrypted password + * \param authenticator The name of the auth provider service used to log the user in, defaults to "Database". + * \return The user's ID if valid; 0 otherwise + */ + static inline UserId addUser(const QString &userName, const QString &password, const QString &authenticator = "Database") { + return instance()->_storage->addUser(userName, password, authenticator); + } + + //! Does a comparison test against the authenticator in the database and the authenticator currently in use for a UserID. + /** + * \param userid The user's ID (note: not login name). + * \param authenticator The name of the auth provider service used to log the user in, defaults to "Database". + * \return True if the userid was configured with the passed authenticator, false otherwise. + */ + static inline bool checkAuthProvider(const UserId userid, const QString &authenticator) { + return instance()->_storage->getUserAuthenticator(userid) == authenticator; + } + //! Change a user's password /** * \param userId The user's ID @@ -93,6 +114,13 @@ public: */ static bool changeUserPassword(UserId userId, const QString &password); + //! Check if we can change a user password. + /** + * \param userID The user's ID + * \return true, if we can change their password, false otherwise + */ + static bool canChangeUserPassword(UserId userId); + //! Store a user setting persistently /** * \param userId The users Id @@ -562,7 +590,7 @@ private slots: bool initStorage(const QString &backend, const QVariantMap &settings, bool setup = false); bool initAuthenticator(const QString &backend, const QVariantMap &settings, bool setup = false); - + void socketError(QAbstractSocket::SocketError err, const QString &errorString); void setupClientSession(RemotePeer *, UserId); @@ -583,12 +611,12 @@ private: bool registerStorageBackend(Storage *); void unregisterStorageBackends(); void unregisterStorageBackend(Storage *); - + void registerAuthenticatorBackends(); bool registerAuthenticatorBackend(Authenticator *); void unregisterAuthenticatorBackends(); void unregisterAuthenticatorBackend(Authenticator *); - + bool selectBackend(const QString &backend); bool createUser(); bool saveBackendSettings(const QString &backend, const QVariantMap &settings);