mirror of
https://gitlab.com/comunic/comunicterm
synced 2024-12-25 13:08:54 +00:00
Added a mode to get only user tokens
This commit is contained in:
parent
3ddaca2376
commit
c48659057e
@ -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
|
||||
|
@ -11,7 +11,7 @@ class LoginScreen
|
||||
public:
|
||||
LoginScreen();
|
||||
|
||||
bool exec();
|
||||
bool exec(bool startApp = true);
|
||||
|
||||
private:
|
||||
void getCredentials(std::string &email, std::string &pass);
|
||||
|
33
main.cpp
33
main.cpp
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user