forked from TWS/kalkutago
Compare commits
3 commits
f32a188750
...
003383e455
Author | SHA1 | Date | |
---|---|---|---|
D. Scott Boggs | 003383e455 | ||
D. Scott Boggs | 5aa16762f7 | ||
D. Scott Boggs | db3ef7640a |
1
Makefile
1
Makefile
|
@ -7,6 +7,7 @@ client/dist/index.html:
|
|||
build-client: client/dist/index.html
|
||||
|
||||
start-server: build-client
|
||||
-mkdir db.mount
|
||||
docker compose up --build -d
|
||||
|
||||
clean:
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
import { RouterLink } from 'vue-router';
|
||||
import { error } from '../error'
|
||||
import router from "../router";
|
||||
import { state } from '../state'
|
||||
|
||||
async function logOut() {
|
||||
const result = await fetch('/api/v1/auth', {method: 'DELETE'})
|
||||
if(!result.ok) return error('failed to log out')
|
||||
console.debug('logged out')
|
||||
state.user = undefined
|
||||
router.push('/login')
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -3,38 +3,38 @@ import { ref, computed } from 'vue'
|
|||
import { state } from '../state';
|
||||
import router from '../router'
|
||||
|
||||
const name = ref("")
|
||||
const password = ref("")
|
||||
const $name = ref("")
|
||||
const $password = ref("")
|
||||
const signUpWait = ref(false)
|
||||
const loginWait = ref(false)
|
||||
const signUpClass = computed(() => `submit button is-success ${signUpWait.value ? 'is-loading' : ''}`)
|
||||
const loginClass = computed(() => `submit button is-info ${loginWait.value ? 'is-loading' : ''}`)
|
||||
|
||||
async function signUp() {
|
||||
const $name = name.value
|
||||
const name = $name.value, password = $password.value
|
||||
signUpWait.value = true
|
||||
const result = await fetch("/api/v1/auth", {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name: $name, password: password.value }),
|
||||
body: JSON.stringify({ name, password }),
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
})
|
||||
if (result.ok) {
|
||||
state.user = { name: $name }
|
||||
state.user = { name }
|
||||
await state.repopulate()
|
||||
router.push("/")
|
||||
}
|
||||
}
|
||||
|
||||
async function login() {
|
||||
const $name = name.value
|
||||
const name = $name.value, password = $password.value
|
||||
loginWait.value = true
|
||||
const result = await fetch("/api/v1/auth", {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ name: $name, password: password.value }),
|
||||
body: JSON.stringify({ name, password }),
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
})
|
||||
if (result.ok) {
|
||||
state.user = { name: $name }
|
||||
state.user = { name }
|
||||
await state.repopulate()
|
||||
router.push("/")
|
||||
}
|
||||
|
@ -54,14 +54,14 @@ if(state.user?.name) router.push("/")
|
|||
<div class="field">
|
||||
<label for="username" class=label>Name</label>
|
||||
<div class="control">
|
||||
<input type="text" name="username" class="input" v-model="name" />
|
||||
<input type="text" name="username" class="input" v-model="$name" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="password" class="label">Password</label>
|
||||
<div class="control">
|
||||
<input type="password" name="password" class="input" v-model="password" />
|
||||
<input type="password" name="password" class="input" v-model="$password" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
|
Loading…
Reference in a new issue