page for list of rooms
This commit is contained in:
@@ -3,23 +3,40 @@ import { ref } from 'vue';
|
||||
|
||||
const email = ref<string>("");
|
||||
const pass = ref<string>("");
|
||||
const text = ref<string>("");
|
||||
|
||||
function login(e: SubmitEvent) {
|
||||
const emit = defineEmits(['nextPage']);
|
||||
|
||||
async function login(e: SubmitEvent) {
|
||||
text.value = "";
|
||||
e.preventDefault();
|
||||
fetch("http://localhost:3000/login", {
|
||||
const res = await fetch("http://localhost:3000/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ email: email.value, pass: pass.value }),
|
||||
headers: new Headers({'content-type': 'application/json'})
|
||||
});
|
||||
if (res.ok) {
|
||||
cookieStore.set("loggedIn", "true");
|
||||
emit('nextPage');
|
||||
} else {
|
||||
text.value = await res.text();
|
||||
}
|
||||
}
|
||||
|
||||
function signup(e: Event) {
|
||||
async function signup(e: Event) {
|
||||
text.value = "";
|
||||
e.preventDefault();
|
||||
fetch("http://localhost:3000/createUser", {
|
||||
const res = await fetch("http://localhost:3000/createUser", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ email: email.value, pass: pass.value, name: email.value.split("@")[0] }),
|
||||
headers: new Headers({'content-type': 'application/json'})
|
||||
});
|
||||
if (res.ok) {
|
||||
cookieStore.set("loggedIn", "true");
|
||||
emit('nextPage');
|
||||
} else {
|
||||
text.value = await res.text();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -32,5 +49,6 @@ function signup(e: Event) {
|
||||
<input type="password" id="pass" v-model="pass"/> <br>
|
||||
<button type="submit">Sign in</button> <br>
|
||||
<button type="button" @click="signup">Sign up</button>
|
||||
<p>{{ text }}</p>
|
||||
</form>
|
||||
</template>
|
||||
Reference in New Issue
Block a user