diff --git a/js/registered.js b/js/registered.js new file mode 100644 index 0000000..d4ab130 --- /dev/null +++ b/js/registered.js @@ -0,0 +1,19 @@ +versionDisplay() +init() + +async function init(){ + let result = await getQuery('res') + if (result == 'success') { + document.getElementById('reg_success').style = 'display:block' + } else if (result =='fail') { + let reason = await getQuery('rsn') + document.getElementById('reg_fail').style = 'display:block' + if (reason != 'false') { + document.getElementById('fail_msg').style = 'display:block' + document.getElementById('fail_reason').textContent = reason + } + } else { + document.getElementById('other').style = 'display:block' + } + hideLoading() +} \ No newline at end of file diff --git a/js/settings.js b/js/settings.js index e7fec42..8a7e2d6 100644 --- a/js/settings.js +++ b/js/settings.js @@ -88,20 +88,25 @@ async function register() { // Registers a device by sending POST request to API redirect: 'follow', body: JSON.stringify({email: email}) }) + let regState, regMsg if (res.status == 201) { - showDone() - hideLoading() + regState = 'success' + regMsg = 'ok' return } else if (res.status == 403) { log(`settings.register: Error: Fetch returned: ${res.body['errorCode']}`, 'err') document.getElementsByName('eml')[0].placeholder = 'Not Authorised' + regState = 'fail' + regMsg = 'Unauthorised email domain' } + window.location.assign(`./registered?res=${regState}&msg=${regMsg}`) } else { logout() } } async function logout() { // Simply removed the UUID from localstorage + // A request to delete the UUID should be sent to the server. localStorage.removeItem('uuid') location.reload() return diff --git a/registered.html b/registered.html new file mode 100644 index 0000000..e0f7ddc --- /dev/null +++ b/registered.html @@ -0,0 +1,73 @@ + + + + +
+ + + + + + + + + + + + + +Loading
+An email containing a magic link has been sent
+Click the link on the device that you want to use OwlBoard on - don't + worry, you can use the same address to sign up on another device
+Do note that you will only be signed in in the browser you open the link with + and can only be used once
+Do check your spam or junk folder if you don't see the email in the + next ten minutes.
+For your privacy, only the 'host' part of your email address has been stored for example "@owlboard.info"
+Sorry, we couldn't sign you up at the moment.
+The error message is:
+Please try again later, if you still can't sign up then check that + you are using a valid railway email address. You can + submit an issue if you think there is something wrong on our end.
+Sorry, we don't know if the signup worked, do check your emails and + try again if you don't receive one from us.
+Enter your work email address:
One registration confirmation email will be sent which will include more details about your account
-Your address will not be stored
+One registration confirmation email will be sent, your email address will not be stored after sending
+Do check your spam/junk folder.
If your domain is not authorised and you are a using a railway company email address, submit an issue and it can be added.
diff --git a/sw.js b/sw.js index e57edfe..dababfb 100644 --- a/sw.js +++ b/sw.js @@ -35,6 +35,7 @@ const dynamicCache = [ '/settings.html', '/pis.html', 'stats.html', + 'registered.html', '/manifest.json', '/styles/board.css', '/styles/find-code.css', @@ -53,7 +54,8 @@ const dynamicCache = [ '/js/settings.js', '/js/simple-board.js', '/js/pis.js', - '/js/stats.js' + '/js/stats.js', + '/js/registered.js' ] for(let i = 0; i < dynamicCache.length; i++) {