@@ -783,6 +783,11 @@ private function validateToken($token, $user = null) {
783783 try {
784784 $ dbToken = $ this ->tokenProvider ->getToken ($ token );
785785 } catch (InvalidTokenException $ ex ) {
786+ $ this ->logger ->warning ('Session token is invalid because it does not exist ' , [
787+ 'app ' => 'core ' ,
788+ 'user ' => $ user ,
789+ 'exception ' => $ ex ,
790+ ]);
786791 return false ;
787792 }
788793
@@ -802,6 +807,10 @@ private function validateToken($token, $user = null) {
802807 }
803808
804809 if (!$ this ->checkTokenCredentials ($ dbToken , $ token )) {
810+ $ this ->logger ->warning ('Session token credentials are invalid ' , [
811+ 'app ' => 'core ' ,
812+ 'user ' => $ user ,
813+ ]);
805814 return false ;
806815 }
807816
@@ -877,28 +886,40 @@ public function loginWithCookie($uid, $currentToken, $oldSessionId) {
877886 $ tokens = $ this ->config ->getUserKeys ($ uid , 'login_token ' );
878887 // test cookies token against stored tokens
879888 if (!in_array ($ currentToken , $ tokens , true )) {
880- $ this ->logger ->info ('Tried to log in {uid} but could not verify token ' , [
889+ $ this ->logger ->info ('Tried to log in but could not verify token ' , [
881890 'app ' => 'core ' ,
882- 'uid ' => $ uid ,
891+ 'user ' => $ uid ,
883892 ]);
884893 return false ;
885894 }
886895 // replace successfully used token with a new one
887896 $ this ->config ->deleteUserValue ($ uid , 'login_token ' , $ currentToken );
888897 $ newToken = $ this ->random ->generate (32 );
889898 $ this ->config ->setUserValue ($ uid , 'login_token ' , $ newToken , (string )$ this ->timeFactory ->getTime ());
899+ $ this ->logger ->debug ('Remember-me token replaced ' , [
900+ 'app ' => 'core ' ,
901+ 'user ' => $ uid ,
902+ ]);
890903
891904 try {
892905 $ sessionId = $ this ->session ->getId ();
893906 $ token = $ this ->tokenProvider ->renewSessionToken ($ oldSessionId , $ sessionId );
907+ $ this ->logger ->debug ('Session token replaced ' , [
908+ 'app ' => 'core ' ,
909+ 'user ' => $ uid ,
910+ ]);
894911 } catch (SessionNotAvailableException $ ex ) {
895- $ this ->logger ->warning ('Could not renew session token for {uid} because the session is unavailable ' , [
912+ $ this ->logger ->critical ('Could not renew session token for {uid} because the session is unavailable ' , [
896913 'app ' => 'core ' ,
897914 'uid ' => $ uid ,
915+ 'user ' => $ uid ,
898916 ]);
899917 return false ;
900918 } catch (InvalidTokenException $ ex ) {
901- $ this ->logger ->warning ('Renewing session token failed ' , ['app ' => 'core ' ]);
919+ $ this ->logger ->error ('Renewing session token failed ' , [
920+ 'app ' => 'core ' ,
921+ 'user ' => $ uid ,
922+ ]);
902923 return false ;
903924 }
904925
@@ -937,10 +958,17 @@ public function logout() {
937958 $ this ->manager ->emit ('\OC\User ' , 'logout ' , [$ user ]);
938959 if ($ user !== null ) {
939960 try {
940- $ this ->tokenProvider ->invalidateToken ($ this ->session ->getId ());
961+ $ token = $ this ->session ->getId ();
962+ $ this ->tokenProvider ->invalidateToken ($ token );
963+ $ this ->logger ->debug ('Session token invalidated before logout ' , [
964+ 'user ' => $ user ->getUID (),
965+ ]);
941966 } catch (SessionNotAvailableException $ ex ) {
942967 }
943968 }
969+ $ this ->logger ->debug ('Logging out ' , [
970+ 'user ' => $ user === null ? null : $ user ->getUID (),
971+ ]);
944972 $ this ->setUser (null );
945973 $ this ->setLoginName (null );
946974 $ this ->setToken (null );
0 commit comments