aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
This commit is contained in:
parent
763ffcfaa6
commit
c717045f18
20
src/main.cpp
20
src/main.cpp
@ -6,6 +6,7 @@
|
||||
#include <csignal>
|
||||
#include <curl/curl.h>
|
||||
#include <curses.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
@ -23,6 +24,18 @@ int main(int argc, char **argv) {
|
||||
// error signal handlers
|
||||
signal(SIGSEGV, safe_exit);
|
||||
|
||||
{
|
||||
std::string savedir_path = std::getenv("HOME");
|
||||
savedir_path.append("/.local/share/bakatui");
|
||||
std::string urlfile_path = std::string(savedir_path) + "/url";
|
||||
std::ifstream urlfile;
|
||||
urlfile.open(urlfile_path);
|
||||
urlfile >> baka_api_url;
|
||||
urlfile.close();
|
||||
}
|
||||
|
||||
if (baka_api_url.empty()) {
|
||||
|
||||
std::cout << "enter school bakalari url:\n";
|
||||
while (true) {
|
||||
std::cout << "(or q to quit )";
|
||||
@ -56,8 +69,11 @@ int main(int argc, char **argv) {
|
||||
// std::cin >> password;
|
||||
|
||||
bakaapi::login(username, password);
|
||||
|
||||
main_menu();
|
||||
}
|
||||
} else {
|
||||
bakaapi::is_logged_in();
|
||||
}
|
||||
main_menu();
|
||||
|
||||
return 0;
|
||||
}
|
||||
11
src/net.cpp
11
src/net.cpp
@ -102,14 +102,23 @@ void login(std::string username, std::string password) {
|
||||
std::cerr << "cannot access ~/.local/share/bakatui\n";
|
||||
safe_exit(100);
|
||||
}
|
||||
std::string authfile_path = std::string(savedir_path) + "/auth";
|
||||
{
|
||||
|
||||
std::string authfile_path = std::string(savedir_path) + "/auth";
|
||||
std::ofstream authfile;
|
||||
authfile.open(authfile_path);
|
||||
authfile << response;
|
||||
authfile.close();
|
||||
}
|
||||
|
||||
{
|
||||
std::string urlfile_path = std::string(savedir_path) + "/url";
|
||||
std::ofstream urlfile;
|
||||
urlfile.open(urlfile_path);
|
||||
urlfile << baka_api_url;
|
||||
urlfile.close();
|
||||
}
|
||||
|
||||
json resp_parsed = json::parse(response);
|
||||
|
||||
access_token = resp_parsed["access_token"];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user