Advertisement
cyanerd

Untitled

Jan 29th, 2023
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. function auth()
  2. {
  3.   global $api;
  4.   global $config;
  5.   try {
  6.     $response = $api->post('/auth/login', [
  7.       GuzzleHttp\RequestOptions::JSON => ['email' => $config['login'], 'password' => $config['password']]
  8.     ]);
  9.     $content = json_decode($response->getBody()->getContents());
  10.     $token = $content->token;
  11.     setConfig('token', $token);
  12.  
  13.     $user = request('/user');
  14.     $ucrId = $user->currentCompany->ucrId;
  15.     if (!$ucrId) die('no UCR ID');
  16.     setConfig('UCR', $ucrId);
  17.  
  18.   } catch (Exception $e) {
  19.     echo $e->getMessage();
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement