improve ux of login flow #157

This commit is contained in:
Aleksey Gurianov
2018-07-12 00:20:05 +04:00
parent 25c75011f4
commit f74f9e462c
2 changed files with 14 additions and 5 deletions
+9 -5
View File
@@ -111,18 +111,22 @@ export default class Root extends Component {
onSignIn(provider) {
const newWindow = window.open(
`${BASE_URL}/auth/${provider}/login?from=${encodeURIComponent(location.href)}&site=${siteId}`
`${BASE_URL}/auth/${provider}/login?from=${encodeURIComponent(
location.origin + location.pathname + '?selfClose'
)}&site=${siteId}`
);
let secondsPass = 0;
const checkMsDelay = 100;
const checkMsDelay = 300;
const checkInterval = setInterval(() => {
let shouldProceed;
secondsPass += checkMsDelay;
try {
shouldProceed = newWindow.closed || secondsPass > 30000;
} catch (e) {}
if (newWindow.location.origin === location.origin || secondsPass > 30000) {
if (shouldProceed) {
clearInterval(checkInterval);
secondsPass = 0;
newWindow.close();
api
.getUser()
+5
View File
@@ -5,6 +5,11 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>remark42</title>
<base target="_blank">
<script>
if (window.location.search === '?selfClose') {
window.close();
}
</script>
<link rel="stylesheet" href="remark.css">
<style>
html, body {