try to add storage access request for safari 12 during login

This commit is contained in:
igoradamenko
2018-11-11 22:42:11 +02:00
parent e09678c72f
commit 5e62155445
4 changed files with 52 additions and 27 deletions
@@ -14,6 +14,6 @@
color: #0aa;
&:hover {
color: #06c5c5;
color: #06c5c5;
}
}
@@ -1,5 +1,6 @@
.dropdown__item {
a, button {
a,
button {
display: block;
width: 100%;
text-align: left;
@@ -1,3 +1,3 @@
.dropdown__items {
padding: 5px 0;
padding: 5px 0;
}
+48 -24
View File
@@ -117,33 +117,57 @@ 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) {
// user's browser is safari and we need to request access
document
.hasStorageAccess()
.then(() => {
signIn();
})
.catch(() => {
// if there is an error it means that we don't have access
document
.requestStorageAccess()
.then(() => {
signIn();
})
.catch(() => {
alert(`We can't login you without access to your browser's storage.`);
});
});
} 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() {