<?php

namespace Ministra\Lib\RESTAPI\v1;

use Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2;
class RESTCommandStbAuth extends \Ministra\Lib\RESTAPI\v1\RESTCommand
{
    public function update(\Ministra\Lib\RESTAPI\v1\RESTRequest $request)
    {
        $stb_list = $request->getConvertedIdentifiers();
        if (empty($stb_list)) {
            throw new \Ministra\Lib\RESTAPI\v1\RESTCommandException('Empty stb list');
        }
        foreach ($stb_list as $uid) {
            \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->update('users', ['access_token' => \strtoupper(\md5(\microtime(1) . \uniqid()))], ['id' => $uid]);
            if ($request->getData('reset_device_id')) {
                \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->update('users', ['mac' => '', 'device_id' => '', 'device_id2' => ''], ['id' => $uid]);
            }
            \Ministra\Lib\w13ec15f0067ea75861e61e27c990e4ba\d3507c2999d38573a0a0c91771d70af2::getInstance()->update('access_tokens', ['token' => 'invalid_' . \md5(\microtime(1) . \uniqid()), 'refresh_token' => 'invalid_' . \md5(\microtime(1) . \uniqid())], ['uid' => $uid]);
        }
        return true;
    }
}
