-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Google Sign-On with new libraries #5777
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
{% set srOnly = (showLabels == true) ? "" : "sr-only" %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
{% if displayGoogleSignin %} | ||
<meta name="google-signin-client_id" content="{{ googleSigninClientID|attr }}"> | ||
{% endif %} | ||
<script src="https://accounts.google.com/gsi/client" async defer></script> | ||
<div id="g_id_onload" | ||
data-client_id="{{ googleSigninClientID }}" | ||
Saparbek-Nagashibekov marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to html escape this via attr:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, how to do that ? could you give your suggested change? I will add it. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i should of been more clear. you pipe it through the attr to html escape it there (see line below):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does it mean "html escape this via attr" how can I do that? Could you give me sample. thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here is what the line should look like (see where the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Brady, |
||
data-callback="onSignInSuccess" data-auto_prompt="false"> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this block of code be within the above if conditional in line 4? |
||
|
||
<title>{{ title|text }} {{ "Login"|xlt }}</title> | ||
{% block head %}{% endblock %} | ||
<script src="{{ webroot|attr }}/interface/product_registration/product_registration_service.js?v={{ assetVersion|attr_url }}"></script> | ||
|
@@ -103,7 +108,8 @@ | |
</div> | ||
{% endif %} | ||
|
||
<div class="form-group d-flex justify-content-end"> | ||
<div class="form-group d-flex " style="justify-content: space-between !important;" > | ||
{% if displayGoogleSignin %} <div class="g_id_signin" data-type="standard" ></div> {% endif %} | ||
<button id="login-button" class="btn btn-primary" type="submit" onclick="transmit_form(this)">{{ "Login"|xlt }}</button> | ||
</div> | ||
|
||
|
@@ -203,23 +209,22 @@ | |
|
||
// Click-handler for signin button | ||
function do_google_signin() { | ||
google_signin = true; | ||
google_signin = true; | ||
} | ||
|
||
// When Google sign-in successful, sign in to the app, but only | ||
// if the button was clicked (otherwise we would automatically login) | ||
function onSignInSuccess(googleUser) { | ||
if (google_signin === true) { | ||
const auth_response = googleUser.getAuthResponse(); | ||
const id_token = auth_response.id_token; | ||
|
||
const id_token = googleUser.credential; | ||
$('.login-failure').hide(); | ||
$('#used-google-signin').val(true); | ||
$('#google-signin-token').val(id_token); | ||
$('#google-signout').show(); | ||
$('#standard-auth-username, #standard-auth-password').hide(); | ||
var element = document.getElementById('login-button'); | ||
transmit_form(element); | ||
} | ||
|
||
} | ||
|
||
function onSignInFailure(error) { | ||
|
@@ -250,18 +255,5 @@ | |
}); | ||
} | ||
|
||
$.getScript('https://apis.google.com/js/platform.js', function (data, textStatus, jqxh) { | ||
// When the auth2 library is loaded, log out so the user has to sign into google | ||
gapi.load('auth2', function () { | ||
gapi.auth2.init().then(function () { | ||
signOut(); | ||
}); | ||
}); | ||
|
||
// Render the "Sign in with Google" button | ||
renderButton(); | ||
}).fail(function (jqxhr, settings, exception) { | ||
$('#google-signin-service-unreachable-alert').show(); | ||
}); | ||
</script> | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
above line looks like an unrelated change. If so, would add it back.