Feature/Auth: last one was authentication, this one is authorization #4
@@ -6,16 +6,16 @@ export interface UserDto {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
email: string;
|
email: string;
|
||||||
id: string;
|
id: string;
|
||||||
username: string;
|
userName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegisterDto {
|
export interface RegisterDto {
|
||||||
username: string;
|
userName: string;
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LoginDto {
|
export interface LoginDto {
|
||||||
username: string;
|
userName: string;
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import * as authApi from "../api/AuthApi";
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const user = reactive<LoginDto>({ // the template ensures type consistency
|
const user = reactive<LoginDto>({ // the template ensures type consistency
|
||||||
username: "",
|
userName: "",
|
||||||
password: "",
|
password: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ async function login(): Promise<void> {
|
|||||||
<h2>Login</h2>
|
<h2>Login</h2>
|
||||||
|
|
||||||
<form @submit.prevent="login">
|
<form @submit.prevent="login">
|
||||||
<input v-model="user.username" placeholder="username" />
|
<input v-model="user.userName" placeholder="username" />
|
||||||
<input v-model="user.password" type="password" placeholder="password" />
|
<input v-model="user.password" type="password" placeholder="password" />
|
||||||
|
|
||||||
<button type="submit">Submit</button>
|
<button type="submit">Submit</button>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import * as authApi from "../api/AuthApi";
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const user = reactive<RegisterDto>({ // the template ensures type consistency
|
const user = reactive<RegisterDto>({ // the template ensures type consistency
|
||||||
username: "",
|
userName: "",
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
});
|
});
|
||||||
@@ -40,7 +40,7 @@ async function register(): Promise<void> {
|
|||||||
<h2>Register</h2>
|
<h2>Register</h2>
|
||||||
|
|
||||||
<form @submit.prevent="register">
|
<form @submit.prevent="register">
|
||||||
<input v-model="user.username" placeholder="username" />
|
<input v-model="user.userName" placeholder="username" />
|
||||||
<input v-model="user.email" placeholder="email" />
|
<input v-model="user.email" placeholder="email" />
|
||||||
<input v-model="user.password" placeholder="password" />
|
<input v-model="user.password" placeholder="password" />
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ function logout() {
|
|||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr v-for="user in store.users" :key="user.id">
|
<tr v-for="user in store.users" :key="user.id">
|
||||||
<td>{{ user.username }}</td>
|
<td>{{ user.userName }}</td>
|
||||||
<td>
|
<td>
|
||||||
<button @click="store.removeUser(user.id)">Delete</button>
|
<button @click="store.removeUser(user.id)">Delete</button>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user