FIX: Support create account on facebook browser

This commit is contained in:
Robin Ward 2016-06-10 11:12:46 -04:00
parent dffe50a2e6
commit eff2865278
2 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1,13 @@
export default {
name: "auth-complete",
after: "inject-objects",
initialize() {
if (window.location.search.indexOf('authComplete=true') !== -1) {
const lastAuthResult = localStorage.getItem('lastAuthResult');
if (lastAuthResult) {
Discourse.authenticationComplete(JSON.parse(lastAuthResult));
}
}
}
};

View File

@ -22,12 +22,15 @@
<p><%=t "login.close_window" %></p>
<script type="text/javascript">
var authResult = <%=@auth_result.to_client_hash.to_json.html_safe%>;
// On facebook browser, just redirect and don't close
var ua = navigator.userAgent || navigator.vendor || window.opera;
if ((ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1)) {
window.location.href = '<%= Discourse.base_url.html_safe %>';
localStorage.setItem('lastAuthResult', JSON.stringify(authResult));
window.location.href = '<%= Discourse.base_url.html_safe %>?authComplete=true';
} else {
window.opener.Discourse.authenticationComplete(<%=@auth_result.to_client_hash.to_json.html_safe%>);
window.opener.Discourse.authenticationComplete(authResult);
window.close();
}
</script>