Skip to content

Commit

Permalink
removed Facebook SDK completely from /signin page, in favor of a simp…
Browse files Browse the repository at this point in the history
…le web redirect
  • Loading branch information
albogdano committed Mar 7, 2022
1 parent 05dcc89 commit 7064770
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/erudika/scoold/utils/ScooldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,12 @@ public String getCSPNonce() {
return Utils.generateSecurityToken(16);
}

public String getFacebookLoginURL() {
return "https://www.facebook.com/dialog/oauth?client_id=" + CONF.facebookAppId() +
"&response_type=code&scope=email&redirect_uri=" + getParaEndpoint() +
"/facebook_auth&state=" + getParaAppId();
}

public String getGoogleLoginURL() {
return "https://accounts.google.com/o/oauth2/v2/auth?" +
"client_id=" + CONF.googleAppId() + "&response_type=code&scope=openid%20profile%20email&redirect_uri="
Expand Down Expand Up @@ -1940,6 +1946,9 @@ public String getParaAppId() {
}

public String getFirstConfiguredLoginURL() {
if (!CONF.facebookAppId().isEmpty()) {
return getFacebookLoginURL();
}
if (!CONF.googleAppId().isEmpty()) {
return getGoogleLoginURL();
}
Expand Down
25 changes: 0 additions & 25 deletions src/main/resources/templates/base.vm
Original file line number Diff line number Diff line change
Expand Up @@ -423,31 +423,6 @@
</script>
<script nonce="$cspNonce" src="$!scriptslink/scoold.js"></script>

#if ($request.getServletPath() == $signinlink)
#if($FB_APP_ID && !$FB_APP_ID.isEmpty())
<script nonce="$cspNonce">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v10.0&appId=$!FB_APP_ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
$('#fb-login-btn').on('click', function () {
var that = $(this);
FB.login(function(response) {
if (response.authResponse) {
that.closest("form").find("input[type=hidden]").val(response.authResponse.accessToken).next().click();
} else {
window.location = "${CONTEXT_PATH}/signin?code=3&error=true";
}
}, {scope: 'public_profile,email'});
return false;
});
</script>
#end
#end

#if ($captchakey && !$captchakey.isBlank())
<script nonce="$cspNonce" src="https://www.google.com/recaptcha/api.js"></script>
<script nonce="$cspNonce">function onSubmit() {document.getElementById("captcha-form").submit();}</script>
Expand Down
12 changes: 4 additions & 8 deletions src/main/resources/templates/signin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,15 @@
<div class="row">
<div class="col s12 m12 l8 offset-l2 center">
#if($fbLoginEnabled)
<div class="mvl pvs">
<form action="${CONTEXT_PATH}/signin?provider=facebook" method="POST">
<input type="hidden" name="access_token" value="">
<button type="submit" class="hide">submit</button>
<a id="fb-login-btn" href="#" class="btn-large indigo lighten-1 truncate">
<div class="mvl pvs">
<a id="fb-login-btn" href="$!scooldUtils.facebookLoginURL" class="btn-large indigo lighten-1 truncate">
<i class="fa fa-facebook-official left"></i> $!lang.get("signin.facebook")
</a>
</form>
</div>
</div>
#end

#if($gpLoginEnabled)
<div class="mvl pvs">
<div class="mvl pvs">
<a id="gp-login-btn" href="$!scooldUtils.googleLoginURL" class="btn-large white grey-text text-darken-1 truncate pls prl">
<img src="$imageslink/google.svg" width="54" height="54" alt="Google logo" class="left"/>
$!lang.get("signin.google")
Expand Down

0 comments on commit 7064770

Please sign in to comment.