mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 11:42:05 +00:00
login with fb implemented
This commit is contained in:
parent
1dc37fc934
commit
8718d868bf
2 changed files with 43 additions and 1 deletions
|
|
@ -12,6 +12,17 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
<script>
|
||||||
|
window.fbAsyncInit = function() {
|
||||||
|
FB.init({
|
||||||
|
appId : '1537119779906825',
|
||||||
|
autoLogAppEvents : false,
|
||||||
|
xfbml : false,
|
||||||
|
version : 'v2.5'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script async defer src="https://connect.facebook.net/en_US/sdk.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<%= compilation.assets['main.js'].source() %>
|
<%= compilation.assets['main.js'].source() %>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,39 @@ const Intro = ({ queryParams }) => {
|
||||||
core.off('Event', onEvent);
|
core.off('Event', onEvent);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
const statusChangeCallback = React.useCallback((response) => {
|
||||||
|
if (response.status === 'connected') {
|
||||||
|
fetch(baseUrl + "/fb-login-with-token/" + encodeURIComponent(response.authResponse.accessToken), { timeout: 10 * 1000 })
|
||||||
|
.then((resp) => {
|
||||||
|
if (resp.status < 200 || resp.status >= 300) {
|
||||||
|
throw new Error('Login failed at getting token from Stremio with status ' + resp.status);
|
||||||
|
} else {
|
||||||
|
return resp.json();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
core.dispatch({
|
||||||
|
action: 'UserOp',
|
||||||
|
args: {
|
||||||
|
userOp: 'Login',
|
||||||
|
args: {
|
||||||
|
email: state.email,
|
||||||
|
password: response.authResponse.accessToken
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('Please log into this app.');
|
||||||
|
}
|
||||||
|
}, [state.email, state.password]);
|
||||||
const loginWithFacebook = React.useCallback(() => {
|
const loginWithFacebook = React.useCallback(() => {
|
||||||
alert('TODO: Facebook login');
|
FB.login(function(response) {
|
||||||
|
statusChangeCallback(response);
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
const loginWithEmail = React.useCallback(() => {
|
const loginWithEmail = React.useCallback(() => {
|
||||||
if (typeof state.email !== 'string' || state.email.length === 0) {
|
if (typeof state.email !== 'string' || state.email.length === 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue