Skip to content

Commit

Permalink
cu
Browse files Browse the repository at this point in the history
  • Loading branch information
Twoguini committed Dec 27, 2023
1 parent 9ceb6c0 commit 3050fb1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 41 deletions.
9 changes: 9 additions & 0 deletions src/queries/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createClient } from '@supabase/supabase-js';
import { myApplicationKey, myApplicationURL } from '../secrets.js';

const db = createClient(
myApplicationURL,
myApplicationKey
);

export default db;
8 changes: 1 addition & 7 deletions src/queries/getUsersGrades.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { createClient } from '@supabase/supabase-js';
import { myApplicationKey, myApplicationURL } from '../secrets.js';

const db = createClient(
myApplicationURL,
myApplicationKey
);
import db from "./database.js";

const { data, error } = await db
.from('students')
Expand Down
8 changes: 1 addition & 7 deletions src/queries/postUsersGrades.js
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import { createClient } from '@supabase/supabase-js';
import { myApplicationKey, myApplicationURL } from '../secrets.js';

const db = createClient(
myApplicationURL,
myApplicationKey
);
import db from "./database.js";
19 changes: 6 additions & 13 deletions src/queries/usersLogin.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { createClient } from "@supabase/supabase-js";
import { myApplicationKey, myApplicationURL } from "../secrets.js";

const db = createClient(
myApplicationURL,
myApplicationKey
);
import db from "./database.js";

async function verifyLogIn(user, password){

Expand All @@ -13,13 +7,12 @@ async function verifyLogIn(user, password){
.select('*', {count: 'exact', head: true})
.eq('nome', user, 'password', password)

if(count === 0){
return (false);
if (error){
console.error(error)
return false
}
else{
return(true);
};

};
return count >= 1
}

export default verifyLogIn;
16 changes: 2 additions & 14 deletions src/queries/usersSingUp.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import { createClient } from "@supabase/supabase-js";
import { myApplicationKey, myApplicationURL } from "../secrets.js";

const db = createClient (
myApplicationURL,
myApplicationKey
);
import db from "./database.js";

async function createAcc(username, password){

const { error } = await db
.from('students')
.insert({ nome: username, password: password })

if (error){
console.log(error)
return(false)
}
else {
return(true)
}
return !error
};

export default createAcc;

0 comments on commit 3050fb1

Please sign in to comment.