forked from TWS/kalkutago
Compare commits
13 commits
168289335b
...
7d77f50c29
Author | SHA1 | Date | |
---|---|---|---|
D. Scott Boggs | 7d77f50c29 | ||
D. Scott Boggs | 68e9b15da9 | ||
D. Scott Boggs | 4fb02e704c | ||
D. Scott Boggs | b4d524dccb | ||
D. Scott Boggs | 01004e237b | ||
D. Scott Boggs | 149a936638 | ||
D. Scott Boggs | cf8380db35 | ||
D. Scott Boggs | 7ffc176698 | ||
D. Scott Boggs | d8c9594d92 | ||
D. Scott Boggs | 88b58bb19d | ||
D. Scott Boggs | a8a23ff740 | ||
D. Scott Boggs | 17013a0643 | ||
scott | 396ed28079 |
|
@ -1,14 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { RouterLink } from 'vue-router';
|
||||
import { error } from '../error'
|
||||
import router from "../router";
|
||||
|
||||
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')
|
||||
router.push('/login')
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
|
@ -18,27 +9,20 @@ async function logOut() {
|
|||
<div class="navbar-menu"></div>
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<RouterLink to="/" v-if="$route.path === '/new-track'">
|
||||
<button class="button is-info">
|
||||
Go Back
|
||||
</button>
|
||||
</RouterLink>
|
||||
<div class="buttons">
|
||||
<RouterLink to="/" v-if="$route.path === '/new-track'">
|
||||
<button class="button is-info">
|
||||
Go Back
|
||||
</button>
|
||||
</RouterLink>
|
||||
|
||||
<RouterLink to="/new-track" v-else>
|
||||
<button class="button is-primary">
|
||||
Add Track
|
||||
</button>
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div class="navbar-item">
|
||||
<button class="button is-info" @click="logOut">
|
||||
Log Out
|
||||
</button>
|
||||
</div>
|
||||
<div class="navbar-item">
|
||||
<!-- spacer -->
|
||||
|
||||
<RouterLink to="/new-track" v-else>
|
||||
<button class="button is-primary">
|
||||
Add Track
|
||||
</button>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</template>
|
||||
</template>
|
|
@ -2,7 +2,6 @@ import { reactive } from "vue"
|
|||
import { Track } from "./track"
|
||||
import { Tick } from './ticks'
|
||||
import { error } from "./error"
|
||||
import { getCookie } from "./util";
|
||||
|
||||
enum State {
|
||||
Unfetched,
|
||||
|
@ -32,8 +31,6 @@ class AppState {
|
|||
constructor() {
|
||||
this.tracks = new Array<Track>
|
||||
this.state = State.Unfetched
|
||||
const name = getCookie("name")
|
||||
if (name) this.user = { name }
|
||||
}
|
||||
streamUpdatesFromServer() {
|
||||
const source = new EventSource("/api/v1/updates")
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
export function getCookie(key: string): string | null {
|
||||
const start = document.cookie.indexOf(key + '=')
|
||||
if(start === -1) return null
|
||||
let end: number | undefined = document.cookie.indexOf(';', start)
|
||||
if(end === -1)
|
||||
end = undefined
|
||||
return document.cookie.substring(start + key.length + 1, end)
|
||||
}
|
|
@ -69,12 +69,6 @@ pub(super) async fn sign_up(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[delete("/")]
|
||||
pub(super) async fn sign_out(cookies: &CookieJar<'_>) {
|
||||
cookies.remove_private(Cookie::named("user"));
|
||||
cookies.remove(Cookie::named("name"));
|
||||
}
|
||||
|
||||
/// Authentication guard
|
||||
#[derive(Deref)]
|
||||
pub(super) struct Auth(users::Model);
|
||||
|
|
|
@ -114,7 +114,7 @@ pub fn start_server(db: DatabaseConnection) -> Rocket<Build> {
|
|||
"/api/v1/groups",
|
||||
routes![all_groups, group, insert_group, update_group, delete_group],
|
||||
)
|
||||
.mount("/api/v1/auth", routes![auth::login, auth::sign_up, auth::sign_out])
|
||||
.mount("/api/v1/auth", routes![auth::login, auth::sign_up])
|
||||
.mount("/", FileServer::from("/src/public"));
|
||||
|
||||
#[cfg(feature = "unsafe_import")]
|
||||
|
|
19
shell.nix
19
shell.nix
|
@ -2,16 +2,13 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
pkgs.mkShell {
|
||||
name = "kalkutago";
|
||||
nativeBuildInputs = with pkgs.buildPackages; [
|
||||
clang
|
||||
yarn nodejs
|
||||
openssl
|
||||
python3
|
||||
python3Packages.requests
|
||||
python3Packages.ipython
|
||||
rustup
|
||||
docker
|
||||
gnumake
|
||||
nativeBuildInputs = with pkgs.buildPackages; [
|
||||
clang
|
||||
yarn nodejs
|
||||
openssl
|
||||
python3
|
||||
python3Packages.requests
|
||||
python3Packages.ipython
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue