@@ -56,6 +56,10 @@ class SolidLoginAuthHandler {
5656
5757 static const clearSessionKey = 'solidui_clear_session_on_startup' ;
5858
59+ /// SharedPreferences key for persisting the "Stay signed in" preference.
60+
61+ static const staySignedInKey = 'solidui_stay_signed_in' ;
62+
5963 /// Clears the cached login session if a previous session opted out of
6064 /// "Stay signed in". Call this early during login page initialisation.
6165
@@ -68,6 +72,21 @@ class SolidLoginAuthHandler {
6872 }
6973 }
7074
75+ /// Returns the persisted "Stay signed in" preference, defaulting to true.
76+
77+ static Future <bool > getStaySignedIn () async {
78+ final prefs = await SharedPreferences .getInstance ();
79+
80+ return prefs.getBool (staySignedInKey) ?? true ;
81+ }
82+
83+ /// Persists the "Stay signed in" preference.
84+
85+ static Future <void > setStaySignedIn (bool value) async {
86+ final prefs = await SharedPreferences .getInstance ();
87+ await prefs.setBool (staySignedInKey, value);
88+ }
89+
7190 /// Notifies the user that their POD is not initialised, verifies the remote
7291 /// directory structure, and navigates to the appropriate screen (setup wizard
7392 /// or child widget).
@@ -97,6 +116,16 @@ class SolidLoginAuthHandler {
97116
98117 if (! allExists) {
99118 await clearPodStructureInitialised ();
119+
120+ // Schedule session clearance for next startup when the user has
121+ // opted out of staying signed in. We must not call deleteLogIn()
122+ // here because InitialSetupScreen still needs valid auth data.
123+
124+ if (! staySignedIn) {
125+ final prefs = await SharedPreferences .getInstance ();
126+ await prefs.setBool (clearSessionKey, true );
127+ }
128+
100129 if (! context.mounted) return false ;
101130
102131 await pushReplacement (
@@ -109,15 +138,20 @@ class SolidLoginAuthHandler {
109138 );
110139 } else {
111140 await markPodStructureInitialised ();
141+
142+ // Schedule session clearance for next startup when the user has
143+ // opted out of staying signed in. deleteLogIn() must come after
144+ // markPodStructureInitialised() which requires valid auth data.
145+
146+ if (! staySignedIn) {
147+ final prefs = await SharedPreferences .getInstance ();
148+ await prefs.setBool (clearSessionKey, true );
149+ }
150+
112151 if (! context.mounted) return false ;
113152 await pushReplacement (context, childWidget);
114153 }
115154
116- if (! staySignedIn) {
117- final prefs = await SharedPreferences .getInstance ();
118- await prefs.setBool (clearSessionKey, true );
119- }
120-
121155 return true ;
122156 }
123157
@@ -285,6 +319,15 @@ class SolidLoginAuthHandler {
285319
286320 await clearPodStructureInitialised ();
287321
322+ // Schedule session clearance for next startup when the user has
323+ // opted out of staying signed in. We must not call deleteLogIn()
324+ // here because InitialSetupScreen still needs valid auth data.
325+
326+ if (! staySignedIn) {
327+ final prefs = await SharedPreferences .getInstance ();
328+ await prefs.setBool (clearSessionKey, true );
329+ }
330+
288331 if (! context.mounted) return false ;
289332
290333 await pushReplacement (
@@ -297,15 +340,20 @@ class SolidLoginAuthHandler {
297340 );
298341 } else {
299342 await markPodStructureInitialised ();
343+
344+ // Schedule session clearance for next startup when the user has
345+ // opted out of staying signed in. deleteLogIn() must come after
346+ // markPodStructureInitialised() which requires valid auth data.
347+
348+ if (! staySignedIn) {
349+ final prefs = await SharedPreferences .getInstance ();
350+ await prefs.setBool (clearSessionKey, true );
351+ }
352+
300353 if (! context.mounted) return false ;
301354 await pushReplacement (context, childWidget);
302355 }
303356
304- if (! staySignedIn) {
305- final prefs = await SharedPreferences .getInstance ();
306- await prefs.setBool (clearSessionKey, true );
307- }
308-
309357 return true ;
310358 } else {
311359 // solidAuthenticate() returned null. This can happen when:
0 commit comments