<?php

namespace Ministra\Lib\RESTAPI\v1;

use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e;
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\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->update('users', ['access_token' => \strtoupper(\md5(\microtime(1) . \uniqid()))], ['id' => $uid]);
            if ($request->getData('reset_device_id')) {
                \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->update('users', ['mac' => '', 'device_id' => '', 'device_id2' => ''], ['id' => $uid]);
            }
            \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\B4291b8d8fa2d898727b1f446db1e661e::getInstance()->update('access_tokens', ['token' => 'invalid_' . \md5(\microtime(1) . \uniqid()), 'refresh_token' => 'invalid_' . \md5(\microtime(1) . \uniqid())], ['uid' => $uid]);
        }
        return true;
    }
}
