Skip to content

Commit

Permalink
add basic signup page
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Jul 17, 2019
1 parent 8ef3c69 commit 391c78a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
44 changes: 44 additions & 0 deletions apps/signup/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<html>
<h1> User Signup </h1>
If you reach this page, it's likely that you tried to log into this instance but lack access.
Email SOMEONE if you want to be added.

If you are an admin, you should be able to use this form:

<script>
var userSignupUrl = "../../Data/auth/post"
function addUser(){
var email = document.getElementById("name").value
var attrs = JSON.parse(document.getElementById("attr").value)
var doc = {name: email, attrs: attrs}
fetch(userSignupUrl, {
method: 'POST',
mode: 'cors', // no-cors, cors, *same-origin
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'same-origin', // include, *same-origin, omit
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(doc)
}).then(x=>{
if (x.status>=400){
throw "failed to sign up user"
}
x.json()
}).then(x=>{
window.alert("success")
console.log(x)
}).catch(e=>{
window.alert("error!")
console.error(e)
})
}
</script>

<div id="signupForm">
Email: <input id="name" type="text">
Attributes: <input id="attr" type="text">
Submit: <input id="sub" onclick="addUser()" type="submit">
</div>

</html>
4 changes: 3 additions & 1 deletion google_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
var base_deployment_url = window.location.toString().split("/").slice(0,-1).join("/")
var redirect_uri = base_deployment_url + "/login.html"
var default_redirect = base_deployment_url + "/apps/table.html"
var signup_redirect = base_deployment_url + "/apps/signup/signup.html"
let state = decodeURIComponent(getUrlParam("state"))
if (!state || state == "null"){
state = default_redirect
Expand Down Expand Up @@ -60,7 +61,8 @@
document.cookie = cookie_name + "=" + x.token;
window.location = state
} else {
window.alert("no!")
window.alert("User not added.")
window.location = signup_redirect
}

})
Expand Down

0 comments on commit 391c78a

Please sign in to comment.