Skip to content
This repository was archived by the owner on Jun 12, 2019. It is now read-only.

Commit 9d69a76

Browse files
author
Caroline Twigg
committed
delete default organization on auth
1 parent 519a5bb commit 9d69a76

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/auth/auth.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void Auth::authenticate() {
3030
} else {
3131
string err;
3232

33+
Env::instance()->delete_defaults();
3334
Env::instance()->write_credentials(Json::parse(oauth.body, err));
3435
Env::instance()->load_credentials();
3536

src/env/env.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ void Env::write_default_org(std::string org_name) {
121121
FileManager::write(paths.defaults, str);
122122
}
123123

124+
void Env::delete_defaults() {
125+
if(FileManager::file_exists(paths.defaults)){
126+
FileManager::delete_file(paths.defaults);
127+
}
128+
}
129+
124130
void Env::verify_auth() {
125131
if(Env::instance()->authenticated() == false) {
126132
Auth::authenticate();

src/env/env.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Env {
4141
bool load_defaults();
4242
void write_credentials(json11::Json object);
4343
void write_default_org(std::string org_name);
44+
void delete_defaults();
4445
void verify_auth();
4546

4647
private:

src/organization/organization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void Organization::set_default(std::string org_name) {
2525
std::string error_message = json["error"].string_value();
2626

2727
if (error_message.size() > 0) {
28-
console::error("There was an error listing your organizations: " + error_message + "\n");
28+
console::error("There was an error setting your default organization: " + error_message + "\n");
2929
} else {
3030
Env::instance()->write_default_org(org_name);
3131
console::info(org_name + " is now your default organization");

0 commit comments

Comments
 (0)