0

I want to change a value of my config.yml I need to change it from my DefaultController.php but I don't know if this is possible (and if it's possible how to do it).

The YAML file

 google:
    enabled: true          # If Google Authenticator should be enabled, default false
    server_name: Zioo      # Server name used in QR code
    issuer: Zioo           # Issuer name used in QR code
    template: ZPAdminBundle:Authentication:form.html.twig   # Template used to render the authentication form

I need to change "enabled" to false from the defaultcontroller when A user doesn't want to use this option.

Anthon
  • 69,918
  • 32
  • 186
  • 246
Marco Koopman
  • 126
  • 2
  • 14
  • Information on the bundle that the configuration relates too would be nice. You cannot actually modify the YAML configuration at runtime but in most cases the bundle will populate a value object that you can access from the container. Although this may still not work as the bundle might have done its duty before your controller. So please provide the bundle information also then you might get some answers. – Matthew Usurp Mar 22 '17 at 14:42
  • Thanks for the response! The documentation can be found here: https://github.com/scheb/two-factor-bundle/blob/master/Resources/doc/configuration.md I however can't find anything about enabling/disabling the "enabled" option – Marco Koopman Mar 22 '17 at 14:47

1 Answers1

1

Got a fix!

In user I made an IsActivated value for the GoogleAuth

 /**
 * @return mixed
 */
public function getGoogleAuthenticatorIsActivated()
{
    return $this->googleAuthenticatorIsActivated;
}

/**
 * @param mixed $googleAuthenticatorIsActivated
 */
public function setGoogleAuthenticatorIsActivated($googleAuthenticatorIsActivated)
{
    $this->googleAuthenticatorIsActivated = $googleAuthenticatorIsActivated;
}

And then I checked if it is activated. If not it returns NULL. The bundle automaticly disables google auth if "getGoogleAuthenticatorSecret" returns NULL

    public function getGoogleAuthenticatorSecret()
    {

    if($this->getGoogleAuthenticatorIsActivated() == true){
        return $this->googleAuthenticatorSecret;
    }

    return NULL;
    }
Marco Koopman
  • 126
  • 2
  • 14