@@ -40,14 +40,25 @@ public function initialize(array $config): void
4040 parent ::initialize ($ config );
4141
4242 if (Configure::read ('OneTimePasswordAuthenticator.login ' )) {
43- $ this ->tfa = new TwoFactorAuth (
44- qrcodeprovider: Configure::read ('OneTimePasswordAuthenticator.qrcodeprovider ' ),
45- issuer: Configure::read ('OneTimePasswordAuthenticator.issuer ' ),
46- digits: Configure::read ('OneTimePasswordAuthenticator.digits ' ),
47- period: Configure::read ('OneTimePasswordAuthenticator.period ' ),
48- algorithm: Configure::read ('OneTimePasswordAuthenticator.algorithm ' ),
49- rngprovider: Configure::read ('OneTimePasswordAuthenticator.rngprovider ' )
50- );
43+ try {
44+ $ this ->tfa = new TwoFactorAuth (
45+ qrcodeprovider: Configure::read ('OneTimePasswordAuthenticator.qrcodeprovider ' ),
46+ issuer: Configure::read ('OneTimePasswordAuthenticator.issuer ' ),
47+ digits: Configure::read ('OneTimePasswordAuthenticator.digits ' ),
48+ period: Configure::read ('OneTimePasswordAuthenticator.period ' ),
49+ algorithm: Configure::read ('OneTimePasswordAuthenticator.algorithm ' ),
50+ rngprovider: Configure::read ('OneTimePasswordAuthenticator.rngprovider ' )
51+ );
52+ } catch (\Throwable $ t ) {
53+ throw new \RuntimeException (
54+ __d (
55+ 'cake_d_c/users ' ,
56+ 'An error has occurred configuring OneTimePasswordAuthenticator. ' .
57+ 'Please ensure you have installed robthree/twofactorauth and endroid/qr-code ' .
58+ '(or your preferred QR provider). '
59+ )
60+ );
61+ }
5162 }
5263 }
5364
0 commit comments