示例#1
0
 /**
  * Upload the file to the slave
  *
  */
 public function handle()
 {
     $client = new Client();
     try {
         $response = $client->post($this->slave . ApiUrl::$upload . '?token=' . getMasterPassword(), ['multipart' => [['name' => 'file', 'contents' => fopen($this->getFilePath(), 'r')], ['name' => 'force', 'contents' => $this->force ? '1' : '0'], ['name' => 'filename', 'contents' => $this->filename]], 'timeout' => $this->timeout]);
     } catch (\Exception $e) {
     }
 }
示例#2
0
 /**
  * Send Rename request to slave
  *
  */
 public function handle()
 {
     $client = new Client();
     try {
         $response = $client->patch($this->slave . ApiUrl::$rename . '/' . $this->from . '/' . $this->to . '?token=' . getMasterPassword());
     } catch (\Exception $e) {
     }
 }
示例#3
0
 /**
  * Check if info or master password is set as token in the request
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param string $tokenType
  * @return mixed
  */
 public function handle($request, Closure $next, $tokenType)
 {
     $token = $request->input('token') ?: $request->header('TOKEN');
     if ($tokenType == 'info') {
         if ($token != getInfoPassword()) {
             abort(401);
         }
     }
     if ($tokenType == 'master') {
         if ($token != getMasterPassword()) {
             abort(401);
         }
     }
     return $next($request);
 }