mirror of
https://github.com/Damillora/Shioriko.git
synced 2024-11-22 04:17:33 +00:00
feat: register page
This commit is contained in:
parent
ee2b7a50c3
commit
4cac39e83f
@ -11,7 +11,7 @@ type ErrorResponse struct {
|
|||||||
|
|
||||||
type UserProfileResponse struct {
|
type UserProfileResponse struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Username string `json:"password"`
|
Username string `json:"username"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlobResponse struct {
|
type BlobResponse struct {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
import Upload from "./routes/Upload.svelte";
|
import Upload from "./routes/Upload.svelte";
|
||||||
import Edit from "./routes/Edit.svelte";
|
import Edit from "./routes/Edit.svelte";
|
||||||
import Tags from "./routes/Tags.svelte";
|
import Tags from "./routes/Tags.svelte";
|
||||||
|
import Register from "./routes/Register.svelte";
|
||||||
|
|
||||||
export let url = "";
|
export let url = "";
|
||||||
let baseURL = window.BASE_URL;
|
let baseURL = window.BASE_URL;
|
||||||
@ -27,6 +28,7 @@
|
|||||||
<Route path="/auth/logout" component={Logout} />
|
<Route path="/auth/logout" component={Logout} />
|
||||||
<Route path="/upload" component={Upload} />
|
<Route path="/upload" component={Upload} />
|
||||||
<Route path="/tags" component={Tags} />
|
<Route path="/tags" component={Tags} />
|
||||||
|
<Route path="/auth/register" component={Register} />
|
||||||
</div>
|
</div>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
||||||
|
@ -21,6 +21,21 @@ export async function login({ username, password }) {
|
|||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function register({ email, username, password }) {
|
||||||
|
const endpoint = url + "/api/user/register";
|
||||||
|
const response = await axios({
|
||||||
|
url: endpoint,
|
||||||
|
method: "POST",
|
||||||
|
data: JSON.stringify({
|
||||||
|
email,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
token.set(response.data.token);
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getTags() {
|
export async function getTags() {
|
||||||
const endpoint = url + "/api/tag";
|
const endpoint = url + "/api/tag";
|
||||||
const response = await axios.get(endpoint);
|
const response = await axios.get(endpoint);
|
||||||
@ -89,7 +104,7 @@ export async function postCreate({ blob_id, source_url, tags }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function postUpdate(id, { source_url, tags }) {
|
export async function postUpdate(id, { source_url, tags }) {
|
||||||
const endpoint = url + "/api/post/"+id;
|
const endpoint = url + "/api/post/" + id;
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
url: endpoint,
|
url: endpoint,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -103,8 +118,8 @@ export async function postUpdate(id, { source_url, tags }) {
|
|||||||
})
|
})
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
export async function postDelete({id}) {
|
export async function postDelete({ id }) {
|
||||||
const endpoint = url + "/api/post/"+id;
|
const endpoint = url + "/api/post/" + id;
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
url: endpoint,
|
url: endpoint,
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
|
68
web/app/src/routes/Register.svelte
Normal file
68
web/app/src/routes/Register.svelte
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<script>
|
||||||
|
import { register } from "../api.js";
|
||||||
|
import { navigate } from "svelte-routing";
|
||||||
|
|
||||||
|
let username = "";
|
||||||
|
let password = "";
|
||||||
|
let email = "";
|
||||||
|
|
||||||
|
const doRegister = async () => {
|
||||||
|
const tokenData = await register({ email, username, password });
|
||||||
|
navigate("/");
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section class="hero is-primary">
|
||||||
|
<div class="hero-body">
|
||||||
|
<p class="title">Register</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<form on:submit|preventDefault={doRegister}>
|
||||||
|
<div class="field">
|
||||||
|
<label for="email" class="label">Email</label>
|
||||||
|
<div class="control">
|
||||||
|
<input
|
||||||
|
id="email"
|
||||||
|
class="input"
|
||||||
|
type="text"
|
||||||
|
placeholder="Email"
|
||||||
|
bind:value={email}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="username" class="label">Username</label>
|
||||||
|
<div class="control">
|
||||||
|
<input
|
||||||
|
id="username"
|
||||||
|
class="input"
|
||||||
|
type="text"
|
||||||
|
placeholder="Username"
|
||||||
|
bind:value={username}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="password" class="label">Password</label>
|
||||||
|
<div class="control">
|
||||||
|
<input
|
||||||
|
id="password"
|
||||||
|
class="input"
|
||||||
|
type="password"
|
||||||
|
placeholder="Password"
|
||||||
|
bind:value={password}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-link">Login</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user