Fixed login request

This commit is contained in:
Nicolai Ort 2021-08-18 17:11:20 +02:00
parent 0aab082b17
commit fe43a2212a
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
3 changed files with 6 additions and 14 deletions

View File

@ -46,10 +46,9 @@ export default class Apiclient {
static async login(username, password) {
return (
await axios.post(`https://kauft.es/api/auth/login`, {
await axios.post(`https://kauft.es/api/auth/login`, {}, {
auth: {
username,
password
username, password
}
})
).data;

View File

@ -5,7 +5,9 @@ import Apiclient from '$lib/Apiclient';
$: username = "";
$: password = "";
$: error = "";
UserStore.init();
async function login() {
let login = await Apiclient.login(username, password);
if (login.status != 200 && login.status != 201) {
@ -27,14 +29,13 @@ import Apiclient from '$lib/Apiclient';
<p class="mt-1 text-center text-gray-500 dark:text-gray-400">Please login</p>
<form>
<div class="w-full mt-4">
<input
class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring"
type="text"
placeholder="Username"
aria-label="Username"
value={username}
bind:value={username}
/>
</div>
@ -44,7 +45,7 @@ import Apiclient from '$lib/Apiclient';
type="password"
placeholder="Password"
aria-label="Password"
value={password}
bind:value={password}
/>
</div>
@ -56,6 +57,5 @@ import Apiclient from '$lib/Apiclient';
Login
</button>
</div>
</form>
</div>
</div>

View File

@ -1,7 +0,0 @@
<script>
import '../../app.postcss';
</script>
<div class="bg-white dark:bg-gray-800 h-screen">
<slot />
</div>