includes/sessions.php
changeset 811 5c807fe77020
parent 802 59cce2313f9d
child 815 c2b3b1464224
equal deleted inserted replaced
810:7fd2b8a58ae4 811:5c807fe77020
  4044             'user_id' => $req['user_id'],
  4044             'user_id' => $req['user_id'],
  4045             'temp_password' => $req['temp_password'],
  4045             'temp_password' => $req['temp_password'],
  4046             'respawn_info' => $this->process_login_request(array('mode' => 'getkey'))
  4046             'respawn_info' => $this->process_login_request(array('mode' => 'getkey'))
  4047           )));
  4047           )));
  4048         break;
  4048         break;
       
  4049       case 'logout':
       
  4050         if ( !$this->started )
       
  4051           $this->start();
       
  4052         if ( !isset($req['csrf_token']) )
       
  4053           return array(
       
  4054               'mode' => 'error',
       
  4055               'error' => 'Invalid CSRF token'
       
  4056             );
       
  4057         
       
  4058         if ( $req['csrf_token'] !== $this->csrf_token )
       
  4059           return array(
       
  4060               'mode' => 'error',
       
  4061               'error' => 'Invalid CSRF token'
       
  4062             );
       
  4063         $level = isset($req['level']) && is_int($req['level']) ? $req['level'] : USER_LEVEL_MEMBER;
       
  4064         if ( ($result = $this->logout($level)) === 'success' )
       
  4065         {
       
  4066           return array(
       
  4067             'mode' => 'logout_success'
       
  4068           );
       
  4069         }
       
  4070         else
       
  4071         {
       
  4072           return array(
       
  4073             'mode' => 'error',
       
  4074             'error' => $result
       
  4075           );
       
  4076         }
       
  4077         break;
  4049     }
  4078     }
  4050     
  4079     
  4051   }
  4080   }
  4052   
  4081   
  4053 }
  4082 }