Cavoke  1.1.0
A Platform for creating and hosting multiplayer turn-based board games
Loading...
Searching...
No Matches
authdialog.cpp
1#include "authdialog.h"
2#include "ui_authdialog.h"
3
4AuthDialog::AuthDialog(QWidget *parent)
5 : ui(new Ui::AuthDialog), QDialog(parent) {
6 ui->setupUi(this);
7}
8
9AuthDialog::~AuthDialog() {
10 delete ui;
11}
12
13void AuthDialog::on_acceptButton_clicked() {
14 // connect authenticated status with dialog's successful closing
15 connect(authManager, &cavoke::auth::AuthenticationManager::authenticated,
16 this, &AuthDialog::accept);
17 // authorize through browser
18 authManager->oauth2.grant();
19}
20
21void AuthDialog::on_declineButton_clicked() {
22 qWarning() << "User declined authorization! Unable to proceed.";
23 QDialog::reject();
24}
25
28bool AuthDialog::verifyAuth(QWidget *parent) {
30 // check if user already logged in
31 if (authManager->checkAuthStatus()) {
32 qDebug() << "Already authenticated";
33 return true;
34 }
35 // otherwise launch the dialog and ask the user to log in
36 return AuthDialog(parent).exec() == 1;
37}
static bool verifyAuth(QWidget *parent=nullptr)
Definition: authdialog.cpp:28
static AuthenticationManager & getInstance()
Singleton wrapper.