Skip to content

Commit

Permalink
New fixed code to authenicate user
Browse files Browse the repository at this point in the history
  • Loading branch information
sharmnten committed Dec 24, 2024
1 parent bb2b055 commit e74a7c3
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions dashboard/dashboard-appwrite.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]';

script.onload=()=>{

const client = new Appwrite.Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('67609b010021900fc6e6')
script.onload = async () => {
const client = new Appwrite.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your Appwrite endpoint
.setProject('67609b010021900fc6e6'); // Your Project ID

const functions = new Appwrite.Functions(client);
const account = new Appwrite.Account(client);

const functions = new Appwrite.Functions(client)
const account = new Appwrite.Account(client)
const sessionId = localStorage.getItem("session")
console.log(sessionId)
const session = account.getSession(sessionId)
const result = functions.createExecution("loginPoints")
// Retrieve session ID from localStorage
const sessionId = localStorage.getItem("session");
console.log("Session ID:", sessionId);

if (!sessionId) {
console.error("No session ID found. User might not be logged in.");
return;
}

console.log(result)
try {
// Validate the session
const session = await account.getSession(sessionId);
console.log("Session details:", session);

// Execute the function
const result = await functions.createExecution("loginPoints");
console.log("Function execution result:", result);
} catch (error) {
console.error("Error occurred:", error);
}
};

document.head.appendChild(script);

0 comments on commit e74a7c3

Please sign in to comment.