mirror of
https://github.com/JonasunderscoreJones/dash.jonasjones.dev.git
synced 2025-10-22 21:29:19 +02:00
moved accounts backend to session lib
This commit is contained in:
parent
10cc36000c
commit
e5c9c351e7
3 changed files with 7 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
export const ACCOUNTS_WORKER_URL = 'https://accounts.jonasjones.dev';
|
||||||
|
|
||||||
export function getSessionKey() {
|
export function getSessionKey() {
|
||||||
const match = document.cookie.match(/(^| )sessionKey=([^;]+)/);
|
const match = document.cookie.match(/(^| )sessionKey=([^;]+)/);
|
||||||
return match ? match[2] : null;
|
return match ? match[2] : null;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { navigate } from 'svelte-routing';
|
import { navigate } from 'svelte-routing';
|
||||||
import { setSessionKey } from '$lib/session.js';
|
import { onMount } from 'svelte';
|
||||||
|
import { setSessionKey, ACCOUNTS_WORKER_URL } from '$lib/session.js';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
let email = '';
|
let email = '';
|
||||||
let password = '';
|
let password = '';
|
||||||
|
@ -9,7 +10,7 @@
|
||||||
|
|
||||||
const handleLogin = async () => {
|
const handleLogin = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('https://accounts.jonasjones.dev/login', {
|
const response = await fetch(ACCOUNTS_WORKER_URL + '/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ email, password }),
|
body: JSON.stringify({ email, password }),
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { navigate } from 'svelte-routing';
|
import { navigate } from 'svelte-routing';
|
||||||
import { setSessionKey } from '$lib/session.js';
|
import { setSessionKey, ACCOUNTS_WORKER_URL } from '$lib/session.js';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
let username = '';
|
let username = '';
|
||||||
let firstname = '';
|
let firstname = '';
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
const handleLogin = async () => {
|
const handleLogin = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('https://accounts.jonasjones.dev/register', {
|
const response = await fetch(ACCOUNTS_WORKER_URL + '/register', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ email, password, username, firstname, lastname }),
|
body: JSON.stringify({ email, password, username, firstname, lastname }),
|
||||||
headers: {
|
headers: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue