summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-12 22:23:26 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-12 22:23:26 +0200
commit4659d0efc274f2a955b203ca5b00cf1dfc26d5fc (patch)
treede791031bf883a20932c878cd7a9a5d240dc3a49 /include
parentUpdate room name & avatar on new rooms (diff)
downloadnheko-4659d0efc274f2a955b203ca5b00cf1dfc26d5fc.tar.xz
Implement user registration with reCAPTCHA
fixes #264
Diffstat (limited to 'include')
-rw-r--r--include/LoginPage.h2
-rw-r--r--include/MainWindow.h1
-rw-r--r--include/MatrixClient.h7
-rw-r--r--include/Register.h52
-rw-r--r--include/RegisterPage.h9
-rw-r--r--include/dialogs/ReCaptcha.hpp28
6 files changed, 45 insertions, 54 deletions
diff --git a/include/LoginPage.h b/include/LoginPage.h

index b2b40537..34835229 100644 --- a/include/LoginPage.h +++ b/include/LoginPage.h
@@ -41,7 +41,7 @@ public: signals: void backButtonClicked(); void loggingIn(); - void errorOccured(); + void errorOccurred(); protected: void paintEvent(QPaintEvent *event) override; diff --git a/include/MainWindow.h b/include/MainWindow.h
index e3a5e19d..d747f9b4 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h
@@ -49,6 +49,7 @@ class InviteUsers; class JoinRoom; class LeaveRoom; class Logout; +class ReCaptcha; } class MainWindow : public QMainWindow diff --git a/include/MatrixClient.h b/include/MatrixClient.h
index 46d946c7..69fa72bc 100644 --- a/include/MatrixClient.h +++ b/include/MatrixClient.h
@@ -54,7 +54,8 @@ public: void login(const QString &username, const QString &password) noexcept; void registerUser(const QString &username, const QString &password, - const QString &server) noexcept; + const QString &server, + const QString &session = "") noexcept; void versions() noexcept; void fetchRoomAvatar(const QString &roomid, const QUrl &avatar_url); //! Download user's avatar. @@ -109,6 +110,10 @@ public slots: signals: void loginError(const QString &error); void registerError(const QString &error); + void registrationFlow(const QString &user, + const QString &pass, + const QString &server, + const QString &session); void versionError(const QString &error); void loggedOut(); diff --git a/include/Register.h b/include/Register.h deleted file mode 100644
index ed903172..00000000 --- a/include/Register.h +++ /dev/null
@@ -1,52 +0,0 @@ -/* - * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "Deserializable.h" -#include <QJsonDocument> - -class RegisterRequest -{ -public: - RegisterRequest(); - RegisterRequest(const QString &username, const QString &password); - - QByteArray serialize() noexcept; - - void setPassword(QString password) { password_ = password; }; - void setUser(QString username) { user_ = username; }; - -private: - QString user_; - QString password_; -}; - -class RegisterResponse : public Deserializable -{ -public: - void deserialize(const QJsonDocument &data) override; - - QString getAccessToken() { return access_token_; }; - QString getHomeServer() { return home_server_; }; - QString getUserId() { return user_id_; }; - -private: - QString access_token_; - QString home_server_; - QString user_id_; -}; diff --git a/include/RegisterPage.h b/include/RegisterPage.h
index b98e59de..32f2fcf2 100644 --- a/include/RegisterPage.h +++ b/include/RegisterPage.h
@@ -20,12 +20,17 @@ #include <QLabel> #include <QLayout> #include <QSharedPointer> +#include <memory> class FlatButton; class MatrixClient; class RaisedButton; class TextField; +namespace dialogs { +class ReCaptcha; +} + class RegisterPage : public QWidget { Q_OBJECT @@ -38,6 +43,8 @@ protected: signals: void backButtonClicked(); + void errorOccurred(); + void registering(); private slots: void onBackButtonClicked(); @@ -70,4 +77,6 @@ private: // Matrix client API provider. QSharedPointer<MatrixClient> client_; + //! ReCaptcha dialog. + std::shared_ptr<dialogs::ReCaptcha> captchaDialog_; }; diff --git a/include/dialogs/ReCaptcha.hpp b/include/dialogs/ReCaptcha.hpp new file mode 100644
index 00000000..1eda40c7 --- /dev/null +++ b/include/dialogs/ReCaptcha.hpp
@@ -0,0 +1,28 @@ +#pragma once + +#include <QWidget> + +class FlatButton; +class RaisedButton; + +namespace dialogs { + +class ReCaptcha : public QWidget +{ + Q_OBJECT + +public: + ReCaptcha(const QString &server, const QString &session, QWidget *parent = nullptr); + +protected: + void paintEvent(QPaintEvent *event) override; + +signals: + void closing(); + +private: + FlatButton *openCaptchaBtn_; + RaisedButton *confirmBtn_; + RaisedButton *cancelBtn_; +}; +} // dialogs