@@ -781,6 +781,11 @@ private function validateToken($token, $user = null) {
781781 try {
782782 $ dbToken = $ this ->tokenProvider ->getToken ($ token );
783783 } catch (InvalidTokenException $ ex ) {
784+ $ this ->logger ->warning ('Session token is invalid because it does not exist ' , [
785+ 'app ' => 'core ' ,
786+ 'user ' => $ user ,
787+ 'exception ' => $ ex ,
788+ ]);
784789 return false ;
785790 }
786791
@@ -800,6 +805,10 @@ private function validateToken($token, $user = null) {
800805 }
801806
802807 if (!$ this ->checkTokenCredentials ($ dbToken , $ token )) {
808+ $ this ->logger ->warning ('Session token credentials are invalid ' , [
809+ 'app ' => 'core ' ,
810+ 'user ' => $ user ,
811+ ]);
803812 return false ;
804813 }
805814
@@ -875,28 +884,40 @@ public function loginWithCookie($uid, $currentToken, $oldSessionId) {
875884 $ tokens = $ this ->config ->getUserKeys ($ uid , 'login_token ' );
876885 // test cookies token against stored tokens
877886 if (!in_array ($ currentToken , $ tokens , true )) {
878- $ this ->logger ->info ('Tried to log in {uid} but could not verify token ' , [
887+ $ this ->logger ->info ('Tried to log in but could not verify token ' , [
879888 'app ' => 'core ' ,
880- 'uid ' => $ uid ,
889+ 'user ' => $ uid ,
881890 ]);
882891 return false ;
883892 }
884893 // replace successfully used token with a new one
885894 $ this ->config ->deleteUserValue ($ uid , 'login_token ' , $ currentToken );
886895 $ newToken = $ this ->random ->generate (32 );
887896 $ this ->config ->setUserValue ($ uid , 'login_token ' , $ newToken , (string )$ this ->timeFactory ->getTime ());
897+ $ this ->logger ->debug ('Remember-me token replaced ' , [
898+ 'app ' => 'core ' ,
899+ 'user ' => $ uid ,
900+ ]);
888901
889902 try {
890903 $ sessionId = $ this ->session ->getId ();
891904 $ token = $ this ->tokenProvider ->renewSessionToken ($ oldSessionId , $ sessionId );
905+ $ this ->logger ->debug ('Session token replaced ' , [
906+ 'app ' => 'core ' ,
907+ 'user ' => $ uid ,
908+ ]);
892909 } catch (SessionNotAvailableException $ ex ) {
893- $ this ->logger ->warning ('Could not renew session token for {uid} because the session is unavailable ' , [
910+ $ this ->logger ->critical ('Could not renew session token for {uid} because the session is unavailable ' , [
894911 'app ' => 'core ' ,
895912 'uid ' => $ uid ,
913+ 'user ' => $ uid ,
896914 ]);
897915 return false ;
898916 } catch (InvalidTokenException $ ex ) {
899- $ this ->logger ->warning ('Renewing session token failed ' , ['app ' => 'core ' ]);
917+ $ this ->logger ->error ('Renewing session token failed ' , [
918+ 'app ' => 'core ' ,
919+ 'user ' => $ uid ,
920+ ]);
900921 return false ;
901922 }
902923
@@ -935,10 +956,17 @@ public function logout() {
935956 $ this ->manager ->emit ('\OC\User ' , 'logout ' , [$ user ]);
936957 if ($ user !== null ) {
937958 try {
938- $ this ->tokenProvider ->invalidateToken ($ this ->session ->getId ());
959+ $ token = $ this ->session ->getId ();
960+ $ this ->tokenProvider ->invalidateToken ($ token );
961+ $ this ->logger ->debug ('Session token invalidated before logout ' , [
962+ 'user ' => $ user ->getUID (),
963+ ]);
939964 } catch (SessionNotAvailableException $ ex ) {
940965 }
941966 }
967+ $ this ->logger ->debug ('Logging out ' , [
968+ 'user ' => $ user === null ? null : $ user ->getUID (),
969+ ]);
942970 $ this ->setUser (null );
943971 $ this ->setLoginName (null );
944972 $ this ->setToken (null );
0 commit comments