Auth works but not with cookie
continuous-integration/drone/push Build is passing Details

This commit is contained in:
toqvist 2024-04-06 17:43:57 +02:00
parent 3b5ac81cc3
commit 00cf0d9905
3 changed files with 16 additions and 7 deletions

View File

@ -131,9 +131,11 @@ export const KiosMap = () => {
width={120}
src="/kios-logo.png"
alt="" />
{(myself && myself.name) &&
{(myself && myself.name)
?
<p>Logged in as: {myself.name}</p>
: <p>Logged in</p>
}
{
(!hasAuthCookie() && !authToken) &&

View File

@ -9,10 +9,6 @@ const nonAuthHeaders = {
"Content-Type": "application/json",
}
const authHeaders = {
"Content-Type": "application/json",
}
const getMakers = async () => {
const url = `${API_URL}/api/makers`
console.log("Fetching url:", url)
@ -74,12 +70,18 @@ const getMyself = async (authToken: string) => {
const url = `${API_URL}/api/users/me`
console.log("Fetching url:", url)
const authHeaders = {
"Content-Type": "application/json",
"Authorization": `JWT ${authToken}`,
}
const response = await axios.get(`${API_URL}/api/users/me`, {
withCredentials: true,
headers: authHeaders
});
const user: User = response.data.docs;
const user: User = response.data
console.log(`Fetch result from ${url}`, user)
return user;

View File

@ -13,6 +13,11 @@ const Users: CollectionConfig = {
verify: false, // Require email verification before being allowed to authenticate
maxLoginAttempts: 5, // Automatically lock a user out after X amount of failed logins
lockTime: 600 * 1000, // Time period to allow the max login attempts
cookies: {
secure: true,
sameSite: "lax",
domain: process.env.ASTRO_HOST
},
},
fields: [
// Email added by default