1
0
mirror of https://gitlab.com/comunic/comunicterm synced 2024-07-03 14:09:16 +00:00

Added a mode to get only user tokens

This commit is contained in:
Pierre HUBERT 2020-01-10 15:21:03 +01:00
parent 3ddaca2376
commit c48659057e
3 changed files with 33 additions and 4 deletions

View File

@ -23,7 +23,7 @@ enum CursorPos {
SUBMIT = 2
};
bool LoginScreen::exec()
bool LoginScreen::exec(bool startApp)
{
initscr(); /* Start curses mode */
keypad(stdscr, TRUE); // Listen to function keys

View File

@ -11,7 +11,7 @@ class LoginScreen
public:
LoginScreen();
bool exec();
bool exec(bool startApp = true);
private:
void getCredentials(std::string &email, std::string &pass);

View File

@ -1,19 +1,48 @@
#include <iostream>
#include <helpers/accounthelper.h>
#include "api_request.h"
#include "loginscreen.h"
using namespace std;
int main()
int main(int argc, char **argv)
{
cout << "Comunic Term (c) Pierre HUBERT" << endl;
bool onlyGetTokens = false;
if(argc > 1) {
string arg = argv[1];
// Show help
if(arg == "help") {
cout << "Usage: " << endl;
cout << "* help : Show this help" << endl;
cout << "* getTokens : Get login token ONLY" << endl;
return 0;
}
// Get login tokens
if(arg == "getTokens") {
cout << "Getting only login tokens..." << endl;
onlyGetTokens = true;
}
}
// First, we need to sign in user
if(!LoginScreen().exec()) {
if(!LoginScreen().exec(!onlyGetTokens)) {
cerr << "Could not sign in user!" << endl;
return -1;
}
if(onlyGetTokens) {
const auto tokens = AccountHelper::loginTokens();
cout << "Token 1: " << tokens[0] << endl;
cout << "Token 2: " << tokens[1] << endl;
}
return 0;
}