mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-11-02 02:19:43 +00:00
Initial commit
This commit is contained in:
commit
4d53d83769
73 files changed
+37728
No files matched your search
Executable
+30
@@ -0,0 +1,30 @@
|
||||
import { AuthProvider } from 'react-admin';
|
||||
import { supabase } from '../config';
|
||||
|
||||
export const authProvider: AuthProvider = {
|
||||
login: async ({ username, password }) => {
|
||||
const { data, error } = await supabase.auth.signInWithPassword({
|
||||
email: username,
|
||||
password,
|
||||
});
|
||||
if (error) {
|
||||
throw new Error(error.message);
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
logout: async () => {
|
||||
await supabase.auth.signOut();
|
||||
return Promise.resolve();
|
||||
},
|
||||
checkError: async (error) => {
|
||||
if (error.status === 401 || error.status === 403) {
|
||||
return Promise.reject();
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
checkAuth: async () => {
|
||||
const session = await supabase.auth.getSession();
|
||||
return session.data.session ? Promise.resolve() : Promise.reject();
|
||||
},
|
||||
getPermissions: () => Promise.resolve(),
|
||||
};
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import { supabaseConfig } from '../config';
|
||||
|
||||
export const supabase = createClient(
|
||||
supabaseConfig.url,
|
||||
supabaseConfig.anonKey
|
||||
);
|
||||
|
||||
// Custom data provider wrapper if needed for ra-data-supabase
|
||||
import { supabaseDataProvider } from 'ra-supabase';
|
||||
|
||||
export const dataProvider = supabaseDataProvider(
|
||||
supabase,
|
||||
{
|
||||
resources: {
|
||||
question_packs: 'question_packs',
|
||||
questions: 'questions',
|
||||
profiles: 'profiles',
|
||||
couples: 'couples'
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in new issue
Block a user