-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from janniscloodt/login/loginRegister
Updated Login
- Loading branch information
Showing
8 changed files
with
112 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type {Actions} from "./$types"; | ||
import {env} from "$env/dynamic/public"; | ||
import { goto } from '$app/navigation'; | ||
|
||
export const actions:Actions = { | ||
default: async ({request, fetch, cookies}) => { | ||
|
||
const data = await request.formData(); | ||
const username = data.get('username'); | ||
const password = data.get('password'); | ||
|
||
const response = await fetch(env.PUBLIC_BACKEND_URL, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ username, password }), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('An error occurred during the API call.'); | ||
} | ||
const responseData = await response.json(); | ||
const authToken = responseData.token; | ||
|
||
// Setze das Cookie mit einer Gültigkeitsdauer von 30 Tagen | ||
const expirationDate = new Date(); | ||
expirationDate.setDate(expirationDate.getDate() + 30); | ||
|
||
cookies.set('authToken', authToken, { expires: expirationDate }); | ||
|
||
goto('/'); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type {Actions} from "./$types"; | ||
import {env} from "$env/dynamic/public"; | ||
|
||
export const actions:Actions = { | ||
default: async ({request, fetch}) => { | ||
|
||
const data = await request.formData(); | ||
const username = data.get('username'); | ||
const email = data.get('email') | ||
const password = data.get('password'); | ||
const passwordConfirm = data.get('passwordConfirm'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div class="flex items-center pb-80 justify-center h-screen"> | ||
<form method="post" class="w-full max-w-md bg-white shadow-md rounded-md p-6"> | ||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-semibold mb-2"> | ||
Username | ||
<input class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" type="text"> | ||
</label> | ||
</div> | ||
|
||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-semibold mb-2"> | ||
<input class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" type="password"> | ||
</label> | ||
</div> | ||
|
||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-semibold mb-2"> | ||
Password | ||
<input class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" type="password"> | ||
</label> | ||
</div> | ||
|
||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-semibold mb-2"> | ||
Repeat Password | ||
<input class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-indigo-500" type="password"> | ||
</label> | ||
</div> | ||
|
||
<button class="w-full bg-indigo-500 text-white py-2 rounded-md hover:bg-indigo-600 focus:outline-none" type="submit"> | ||
Sign Up | ||
</button> | ||
<div class="pt-3"> | ||
<a>Already have an Accounr? Click</a> | ||
<a href="../login" class="text-blue-700 underline">here</a> | ||
</div> | ||
|
||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
export default { | ||
content: ['./src/**/*.{html,js,svelte,ts}'], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
} | ||
|