Skip to content

Commit

Permalink
Merge pull request #13155 from kaltura/Ursa-21.11.0-SUP-46575
Browse files Browse the repository at this point in the history
SUP-46575 add OTP field and logic to google auth form to appear under…
  • Loading branch information
noahsol30 authored Feb 27, 2025
2 parents b8bbe08 + 0ef07f7 commit c5bb6af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<div class="error"></div>
<label><span>Email:</span><input type="text" name="email" /></label>
<label><span>Password:</span><input type="password" name="password" /></label>
<label id="otp-label" class="hidden"><span>OTP:</span><input type="text" name="otp" /></label>
<button id="login" type="submit">Login</button>
</form>
<script type="text/javascript">
Expand Down
3 changes: 2 additions & 1 deletion alpha/web/lib/css/googleoauth2.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ a { color: #DDDDDD; }
#google-oauth-form label { display: block; font-size: 12px; line-height: 22px; margin: 10px 0; color: #272929; }
#google-oauth-form label span { float: left; width: 80px; }
#google-oauth-form label input { padding: 2px 5px; border: solid 1px #b5cbd3; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }
#google-oauth-form label input.invalid { border: solid 1px darkred; }
#google-oauth-form label input.invalid { border: solid 1px darkred; }
#google-oauth-form #otp-label.hidden { display: none; }
17 changes: 17 additions & 0 deletions alpha/web/lib/js/googleoauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
$el.find('.error').text('');
var $email = $el.find('input[name=email]');
var $password = $el.find('input[name=password]');
var $otpLabel = $el.find('#otp-label');
var $otpInput = $otpLabel.find('input[name=otp]');
var isHidden = $otpLabel.hasClass('hidden');
$email.removeClass('invalid');
$password.removeClass('invalid');
if(!isHidden && $otpInput.hasClass('invalid') ) {
$otpInput.removeClass('invalid');
}
if (!$email.val()) {
$email.addClass('invalid');
return false;
Expand All @@ -29,6 +35,10 @@
$password.addClass('invalid');
return false;
}
if (!isHidden && !$otpInput.val()) {
$otpInput.addClass('invalid');
return false;
}

var partnerId = getQueryVariable("partnerId");
if (partnerId == false)
Expand All @@ -44,6 +54,9 @@
password: $password.val(),
partnerId: partnerId
};
if ($otpInput.val()){
data.otp = $otpInput.val();
}
callApi(data, onLoginApiSuccess, onLoginApiError);
}
return false;
Expand All @@ -63,6 +76,10 @@
function onLoginApiSuccess(data) {
$('body').removeClass('wait');
if (data.code && data.message) {
if(data.code === "MISSING_OTP" && data.message === "OTP is missing"){
var $otp = $el.find('#otp-label');
$otp.removeClass('hidden');
}
$el.find('.error').text(data.message);
return;
}
Expand Down

0 comments on commit c5bb6af

Please sign in to comment.