try to add storage access request during login, again

This commit is contained in:
igoradamenko
2018-11-12 20:30:17 +02:00
parent 35f8b17ac3
commit 3f2bb253bd
2 changed files with 3044 additions and 3021 deletions
+47 -24
View File
@@ -117,33 +117,56 @@ export default class Root extends Component {
}
onSignIn(provider) {
const newWindow = window.open(
`${BASE_URL}/auth/${provider}/login?from=${encodeURIComponent(
location.origin + location.pathname + '?selfClose'
)}&site=${siteId}`
);
if (document.hasStorageAccess) {
document
.hasStorageAccess()
.then(hasAccess => {
if (!hasAccess) {
return document.requestStorageAccess();
}
console.log('already has storage access'); // eslint-disable-line no-console
})
.then(() => {
// Now we have first-party storage access!
signIn();
})
.catch(() => {
// error obtaining storage access.
console.log('cant get storage access'); // eslint-disable-line no-console
});
} else {
signIn();
}
let secondsPass = 0;
const checkMsDelay = 300;
const checkInterval = setInterval(() => {
let shouldProceed;
secondsPass += checkMsDelay;
try {
shouldProceed = newWindow.closed || secondsPass > 30000;
} catch (e) {}
function signIn() {
const newWindow = window.open(
`${BASE_URL}/auth/${provider}/login?from=${encodeURIComponent(
location.origin + location.pathname + '?selfClose'
)}&site=${siteId}`
);
if (shouldProceed) {
clearInterval(checkInterval);
let secondsPass = 0;
const checkMsDelay = 300;
const checkInterval = setInterval(() => {
let shouldProceed;
secondsPass += checkMsDelay;
try {
shouldProceed = newWindow.closed || secondsPass > 30000;
} catch (e) {}
api
.getUser()
.then(user => {
store.set('user', user);
this.setState({ user });
})
.catch(() => {}); // TODO: we need to handle it and write error to user
}
}, checkMsDelay);
if (shouldProceed) {
clearInterval(checkInterval);
api
.getUser()
.then(user => {
store.set('user', user);
this.setState({ user });
})
.catch(() => {}); // TODO: we need to handle it and write error to user
}
}, checkMsDelay);
}
}
onBlockedUsersShow() {
+2997 -2997
View File
File diff suppressed because it is too large Load Diff