File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -118,11 +118,32 @@ impl LastPassProvider {
118118 }
119119
120120 fn sync_if_needed ( & self ) -> Result < ( ) > {
121+ // Check if we're logged in first
122+ if !self . check_login_status ( ) ? {
123+ return Err ( SecretSpecError :: ProviderOperationFailed (
124+ "LastPass authentication required. Please run 'lpass login <your-email>' first."
125+ . to_string ( ) ,
126+ ) ) ;
127+ }
128+
121129 if self . config . sync_on_access {
122130 self . execute_lpass_command ( & [ "sync" ] ) ?;
123131 }
124132 Ok ( ( ) )
125133 }
134+
135+ fn check_login_status ( & self ) -> Result < bool > {
136+ match self . execute_lpass_command ( & [ "status" ] ) {
137+ Ok ( output) => Ok ( !output. contains ( "Not logged in" ) ) ,
138+ Err ( SecretSpecError :: ProviderOperationFailed ( msg) )
139+ if msg. contains ( "Not logged in" )
140+ || msg. contains ( "LastPass authentication required" ) =>
141+ {
142+ Ok ( false )
143+ }
144+ Err ( e) => Err ( e) ,
145+ }
146+ }
126147}
127148
128149impl Provider for LastPassProvider {
You can’t perform that action at this time.
0 commit comments