diff --git a/app/TwoFAccount.php b/app/TwoFAccount.php index b995b097..1fbea365 100644 --- a/app/TwoFAccount.php +++ b/app/TwoFAccount.php @@ -291,7 +291,7 @@ public function populate(Array $attrib = []) // The Type and Secret attributes are mandatory // All other attributes have default value set by OTPHP - if( strcasecmp($attrib['otpType'], 'totp') == 0 && strcasecmp($attrib['otpType'], 'hotp') == 0 ) { + if( $attrib['otpType'] !== 'totp' && $attrib['otpType'] !== 'hotp' ) { throw \Illuminate\Validation\ValidationException::withMessages([ 'otpType' => __('errors.not_a_supported_otp_type') ]); @@ -307,7 +307,7 @@ public function populate(Array $attrib = []) // Create an OTP object using our secret but with default parameters $secret = $attrib['secretIsBase32Encoded'] === 1 ? $attrib['secret'] : Encoding::base32EncodeUpper($attrib['secret']); - $this->otp = strtolower($attrib['otpType']) === 'totp' ? TOTP::create($secret) : HOTP::create($secret); + $this->otp = $attrib['otpType'] === 'totp' ? TOTP::create($secret) : HOTP::create($secret); // and we change parameters if needed if (array_key_exists('service', $attrib) && $attrib['service']) { diff --git a/resources/js/components/TokenDisplayer.vue b/resources/js/components/TokenDisplayer.vue index d4f78303..8d6201de 100644 --- a/resources/js/components/TokenDisplayer.vue +++ b/resources/js/components/TokenDisplayer.vue @@ -77,18 +77,11 @@ // - Trigger when user use the Advanced form and preview the account: We should have all OTP parameter // to obtain a token, including Secret and otpType which are required - try { - this.internal_otpType = this.otpType.toLowerCase() - } - catch(e) { - //do nothing - } - finally { - this.internal_account = this.account - this.internal_service = this.service - this.internal_icon = this.icon - this.internal_hotpCounter = this.hotpCounter - } + this.internal_service = this.service + this.internal_account = this.account + this.internal_icon = this.icon + this.internal_otpType = this.otpType + this.internal_hotpCounter = this.hotpCounter if( id ) { diff --git a/resources/js/views/twofaccounts/Create.vue b/resources/js/views/twofaccounts/Create.vue index bccdeac9..3961ce32 100644 --- a/resources/js/views/twofaccounts/Create.vue +++ b/resources/js/views/twofaccounts/Create.vue @@ -79,7 +79,7 @@ - +
@@ -108,9 +108,9 @@ - + - +
@@ -161,7 +161,7 @@ imageLink: '', qrcode: null, }), - otpTypes: ['TOTP', 'HOTP'], + otpTypes: ['totp', 'hotp'], digitsChoices: [6,7,8,9,10], secretFormats: [ { text: this.$t('twofaccounts.forms.plain_text'), value: 0 }, @@ -240,7 +240,6 @@ const { data } = await this.form.upload('/api/qrcode/decode', imgdata) this.form.fill(data) - this.form.otpType = this.form.otpType.toUpperCase() this.form.secretIsBase32Encoded = 1 this.form.uri = '' // we don't want the uri because the user can change any otp parameter in the form diff --git a/resources/sass/app.scss b/resources/sass/app.scss index e37b6403..afa7f4af 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -361,6 +361,10 @@ figure.no-icon { margin-bottom: 0 !important; } +.has-uppercased-button .is-toggle { + text-transform: uppercase !important; +} + .control.has-icons-left .icon, .control.has-icons-right .icon { color: inherit; }