Skip to content

Commit

Permalink
moved code from settings to PluginState
Browse files Browse the repository at this point in the history
  • Loading branch information
CDaut committed Oct 11, 2024
1 parent 2e23712 commit 3b1b08e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,8 @@ public class ArtemisSettings implements Configurable {
var logoutButton = new JButton("Logout");
logoutButton.addActionListener(a -> {
// request a logout
boolean loggedOut = PluginState.getInstance().logout();
// clear data iff logout was actually carried out
if (loggedOut) {
ArtemisCredentialsProvider.getInstance().setJwt(null);
ArtemisCredentialsProvider.getInstance().setArtemisPassword(null);
ArtemisSettingsState.getInstance().setJwtExpiry(null);
this.apply();
}
PluginState.getInstance().logout();
this.apply();
});
contentPanel.add(logoutButton, "span 1, growx");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ public static PluginState getInstance() {

/**
* Logs out while displaying a warning if an assessment is still running
*
* @return true iff the logout was completed, false otherwise
*/
public boolean logout() {
public void logout() {
boolean answer = true;
// check if confirmation is necessary because assessment is running
if (isAssessing()) {
Expand All @@ -81,13 +79,17 @@ public boolean logout() {
if (answer) {
this.resetState();

// reset state in settings
ArtemisCredentialsProvider.getInstance().setJwt(null);
ArtemisCredentialsProvider.getInstance().setArtemisPassword(null);
ArtemisSettingsState.getInstance().setJwtExpiry(null);

// reset JBCef cookies iff available
if (JBCefApp.isSupported()) {
CefUtils.resetCookies();
}
}
this.notifyConnectedListeners();
return answer;
}

public void connect() {
Expand Down

0 comments on commit 3b1b08e

Please sign in to comment.