src/Webiny/Login/Login.php
public function generateDeviceValidationToken($username)
    {
        $this->username = $username;
        $validationToken = $this->crypt()->generateRandomString(6, '0123456789');

        $devices = $this->getMeta()->allowedDevices;

        $devices[] = [
            'device'          => $this->getDeviceFingerprint(),
            'created'         => 0,
            'token'           => '',
            'validationToken' => $validationToken,
            'confirmed'       => false
        ];

        $this->getMeta()->allowedDevices = $devices;
        $this->getMeta()->save();

        return $validationToken;
    }
public function generateDeviceValidationToken($username)
    {
        $this->username = $username;
        $validationToken = $this->crypt()->generateRandomString(6, '0123456789');

        $devices = $this->getMeta()->allowedDevices;

        $devices[] = [
            'device'          => $this->getDeviceFingerprint(),
            'created'         => 0,
            'token'           => '',
            'validationToken' => $validationToken,
            'confirmed'       => false
        ];

        $this->getMeta()->allowedDevices = $devices;
        $this->getMeta()->save();

        return $validationToken;
    }
public function generateDeviceValidationToken ( $ username ) { $ this -> username = $ username ; $ validationToken = $ this -> crypt ( ) -> generateRandomString ( 6 , '0123456789' ) ; $ devices = $ this -> getMeta ( ) -> allowedDevices ; $ devices [ ] = [ 'device' => $ this -> getDeviceFingerprint ( ) , 'created' => 0 , 'token' => '' , 'validationToken' => $ validationToken , 'confirmed' => false ] ; $ this -> getMeta ( ) -> allowedDevices = $ devices ; $ this -> getMeta ( ) -> save ( ) ; return $ validationToken ; }
Generates a unique token to authenticate the current device for the given username.

@param $username

@return string
@throws LoginException
@throws \Webiny\Component\Crypt\CryptException
Generates a unique token to authenticate the current device for the given username .