File indexing completed on 2025-01-12 04:33:41

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 #include "librestapi_private_export.h"
0009 #include "restapiabstractjob.h"
0010 
0011 namespace RocketChatRestApi
0012 {
0013 class LIBROCKETCHATRESTAPI_QT_TESTS_EXPORT LoginJob : public RestApiAbstractJob
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit LoginJob(QObject *parent = nullptr);
0018     ~LoginJob() override;
0019 
0020     [[nodiscard]] bool start() override;
0021     [[nodiscard]] bool requireHttpAuthentication() const override;
0022     [[nodiscard]] QString userName() const;
0023     void setUserName(const QString &userName);
0024 
0025     [[nodiscard]] QString password() const;
0026     void setPassword(const QString &password);
0027 
0028     [[nodiscard]] bool canStart() const override;
0029 
0030     [[nodiscard]] QNetworkRequest request() const override;
0031     [[nodiscard]] QJsonDocument json() const;
0032 
0033     [[nodiscard]] QString resume() const;
0034     void setResume(const QString &resume);
0035 
0036     [[nodiscard]] QString code() const;
0037     void setCode(const QString &code);
0038 
0039 Q_SIGNALS:
0040     void loginDone(const QString &authToken, const QString &userId);
0041 
0042 protected:
0043     void onPostRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) override;
0044 
0045 private:
0046     Q_DISABLE_COPY(LoginJob)
0047     QString mUserName;
0048     QString mPassword;
0049     QString mResume;
0050     QString mCode;
0051 };
0052 }