Skip to content
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

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Google Sign-On with new libraries
  • Loading branch information
Saparbek-Nagashibekov committed Sep 22, 2022
commit cd882f845a5caab6d61894e474603a5dbd362171
17 changes: 6 additions & 11 deletions templates/login/login_core.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<!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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to html escape this via attr:

data-client_id="{{ googleSigninClientID|attr }}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@bradymiller bradymiller Sep 24, 2022

Choose a reason for hiding this comment

The 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):

data-client_id="{{ googleSigninClientID|attr }}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Member

@bradymiller bradymiller Sep 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is what the line should look like (see where the |attr is in below line :) ):

data-client_id="{{ googleSigninClientID|attr }}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Brady,
made changes. please check commit 1d831fc
Thanks

Expand All @@ -9,8 +12,8 @@

<title>{{ title|text }} {{ "Login"|xlt }}</title>
{% block head %}{% endblock %}
<script src="{{ webroot|attr }}/interface/product_registration/product_registration_service.js?v={{ assetVersion|attr }}"></script>
<script src="{{ webroot|attr }}/interface/product_registration/product_registration_controller.js?v={{ assetVersion|attr }}"></script>
<script src="{{ webroot|attr }}/interface/product_registration/product_registration_service.js?v={{ assetVersion|attr_url }}"></script>
<script src="{{ webroot|attr }}/interface/product_registration/product_registration_controller.js?v={{ assetVersion|attr_url }}"></script>
{{ setupHeader() }}
<script type="text/javascript">
const registrationTranslations = {{ regTranslations }};
Expand Down Expand Up @@ -213,7 +216,6 @@
// if the button was clicked (otherwise we would automatically login)
function onSignInSuccess(googleUser) {

// const auth_response = googleUser.getAuthResponse();
const id_token = googleUser.credential;
$('.login-failure').hide();
$('#used-google-signin').val(true);
Expand Down Expand Up @@ -252,13 +254,6 @@
$('#standard-auth-username, #standard-auth-password').show();
});
}
/*
$.getScript('https://accounts.google.com/gsi/client', function (data, textStatus, jqxh) {
// When the auth2 library is loaded, log out so the user has to sign into google
// Render the "Sign in with Google" button
renderButton();
}).fail(function (jqxhr, settings, exception) {
$('#google-signin-service-unreachable-alert').show();
}); */

</script>
{% endif %}