Can logout from account.

This commit is contained in:
Pierre HUBERT 2018-11-29 16:12:05 +01:00
parent 56c1e4a88b
commit 2396047204
5 changed files with 38 additions and 0 deletions

View File

@ -16,6 +16,12 @@ bool AccountHelper::signedIn()
return ConfigurationHelper().getAccountTokens().isValid(); return ConfigurationHelper().getAccountTokens().isValid();
} }
void AccountHelper::logout()
{
//Destroy login tokens
ConfigurationHelper().setAccountTokens(AccountLoginTokens());
}
void AccountHelper::login(const AccountLoginRequest &info) void AccountHelper::login(const AccountLoginRequest &info)
{ {
//Create API request //Create API request

View File

@ -27,6 +27,11 @@ public:
*/ */
bool signedIn(); bool signedIn();
/**
* Logout user
*/
void logout();
/** /**
* Perform login * Perform login
* *

View File

@ -1,6 +1,11 @@
#include <QMessageBox>
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "aboutthisappdialog.h" #include "aboutthisappdialog.h"
#include "loginwidget.h"
#include "../helpers/accounthelper.h"
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -23,3 +28,17 @@ void MainWindow::on_actionAbout_this_App_triggered()
{ {
AboutThisAppDialog(this).exec(); AboutThisAppDialog(this).exec();
} }
void MainWindow::on_actionLogout_triggered()
{
if(QMessageBox::question(this, tr("Sign out"), tr("Do you really want to sign out from your account?")) != QMessageBox::Yes)
return;
AccountHelper().logout();
//Display login widget
(new LoginWidget())->show();
//Close this widget
close();
}

View File

@ -26,6 +26,8 @@ private slots:
void on_actionAbout_this_App_triggered(); void on_actionAbout_this_App_triggered();
void on_actionLogout_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
}; };

View File

@ -27,6 +27,7 @@
<property name="title"> <property name="title">
<string>Account</string> <string>Account</string>
</property> </property>
<addaction name="actionLogout"/>
</widget> </widget>
<widget class="QMenu" name="menuHelp"> <widget class="QMenu" name="menuHelp">
<property name="title"> <property name="title">
@ -49,6 +50,11 @@
<string>About this App</string> <string>About this App</string>
</property> </property>
</action> </action>
<action name="actionLogout">
<property name="text">
<string>Logout</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>