This repository was archived by the owner on Jun 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/java/fi/helsinki/cs/tmc/cli/backend Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import fi .helsinki .cs .tmc .cli .io .EnvironmentUtil ;
44import fi .helsinki .cs .tmc .cli .io .WorkDir ;
55
6+ import fi .helsinki .cs .tmc .core .communication .oauth2 .Oauth ;
67import fi .helsinki .cs .tmc .core .configuration .TmcSettings ;
78import fi .helsinki .cs .tmc .core .domain .Course ;
89
1112import fi .helsinki .cs .tmc .core .domain .Organization ;
1213import fi .helsinki .cs .tmc .spyware .SpywareSettings ;
1314import org .apache .http .impl .conn .SystemDefaultRoutePlanner ;
15+ import org .apache .oltu .oauth2 .common .exception .OAuthProblemException ;
16+ import org .apache .oltu .oauth2 .common .exception .OAuthSystemException ;
17+ import org .slf4j .Logger ;
18+ import org .slf4j .LoggerFactory ;
1419
1520import java .nio .file .Path ;
1621import java .util .Locale ;
1722
1823public class Settings implements TmcSettings , SpywareSettings {
1924
25+ private static final Logger logger = LoggerFactory .getLogger (Settings .class );
2026 private WorkDir workDir ;
2127 private Account account ;
2228
@@ -36,6 +42,16 @@ public void setAccount(Account account) {
3642 if (account == null ) {
3743 account = new Account ();
3844 }
45+ try {
46+ Optional <String > password = account .getPassword ();
47+ if (password .isPresent ()) {
48+ Oauth .getInstance ().fetchNewToken (password .get ());
49+ account .setPassword (Optional .absent ());
50+ SettingsIo .saveCurrentSettingsToAccountList (this );
51+ }
52+ } catch (OAuthProblemException | OAuthSystemException var1 ) {
53+ logger .warn ("Settings migration failed." );
54+ }
3955 this .account = account ;
4056 }
4157
You can’t perform that action at this time.
0 commit comments