Files
zitadel/internal/api/ui/login/static/templates/mfa_init_otp.html
Connor 8d40306ee2 fix(login): Copy to clipboard button in MFA login step now compatible in non-chrome browser (#9880)
related to issue [#9379](https://github.com/zitadel/zitadel/issues/9379)

# Which Problems Are Solved

Copy to clipboard button was not compatible with Webkit/ Firefox
browsers.

# How the Problems Are Solved

The previous function used addEventListener without a callback function
as a second argument. I simply added the callback function and left
existing code intact to fix the bug.

# Additional Changes

Added `type=button` to prevent submitting the form when clicking the
button.

# Additional Context

none

---------

Co-authored-by: Livio Spring <livio.a@gmail.com>
(cherry picked from commit 77b433367e)
2025-05-28 10:36:01 +02:00

61 lines
2.2 KiB
HTML

{{template "main-top" .}}
<div class="lgn-head">
<h1>{{t "InitMFAOTP.Title"}}</h1>
{{ template "user-profile" . }}
<p>{{t "InitMFAOTP.Description"}}</p>
</div>
<form action="{{ mfaInitVerifyUrl }}" method="POST">
{{ .CSRF }}
<input type="hidden" name="authRequestID" value="{{ .AuthReqID }}" />
<input type="hidden" name="mfaType" value="{{ .MFAType }}" />
<input type="hidden" name="url" value="{{ .Url }}" />
<input type="hidden" name="secret" value="{{ .Secret }}" />
{{if (eq .MFAType 0) }}
<p>{{t "InitMFAOTP.OTPDescription"}}</p>
<div class="lgn-qrcode" id="qrcode">
{{.QrCode}}
</div>
<div class="fields">
<div class="field">
<span class="lgn-label" for="secret">{{t "InitMFAOTP.SecretLabel"}}</span>
<div class="lgn-row">
<span id="secret"> {{.Secret}} </span>
<span class="fill-space"></span>
<button id="copy" data-copy="{{ .Secret }}" class="lgn-icon-button" type="button">
<i class="lgn-icon-clipboard"></i>
</button>
</div>
</div>
<div class="field">
<label class="lgn-label" for="code">{{t "InitMFAOTP.CodeLabel"}}</label>
<input class="lgn-input" type="text" id="code" name="code" autocomplete="off" autofocus required>
</div>
</div>
{{end}}
<div class="lgn-actions">
<!-- position element in header -->
<a class="lgn-icon-button lgn-left-action" href="{{ mfaPromptChangeUrl .AuthReqID .MFAType }}">
<i class="lgn-icon-arrow-left-solid"></i>
</a>
<a class="lgn-stroked-button" href="{{ loginUrl }}">
{{t "InitMFAOTP.CancelButtonText"}}
</a>
<span class="fill-space"></span>
<button class="lgn-primary lgn-raised-button" id="submit-button" type="submit">{{t "InitMFAOTP.NextButtonText"}}</button>
</div>
</form>
<script src="{{ resourceUrl "scripts/copy_to_clipboard.js" }}"></script>
<script src="{{ resourceUrl "scripts/form_submit.js" }}"></script>
<script src="{{ resourceUrl "scripts/default_form_validation.js" }}"></script>
{{template "main-bottom" .}}