@xouteiro/auth_npm 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -0
- package/dist/index.mjs +15 -0
- package/index.d.ts +4 -0
- package/package.json +2 -1
- package/src/index.js +6 -5
- package/src/login.js +21 -0
package/dist/index.js
CHANGED
@@ -2194,6 +2194,7 @@ __export(index_exports, {
|
|
2194
2194
|
AuthWrapper: () => AuthWrapper,
|
2195
2195
|
LogoutButton: () => LogoutButton,
|
2196
2196
|
isAdmin: () => isAdmin,
|
2197
|
+
signInWithEmail: () => signInWithEmail,
|
2197
2198
|
supabase: () => supabase,
|
2198
2199
|
useAuth: () => useAuth
|
2199
2200
|
});
|
@@ -2273,11 +2274,26 @@ function LogoutButton({ supabaseClient, onLogout }) {
|
|
2273
2274
|
function isAdmin(user) {
|
2274
2275
|
return (user == null ? void 0 : user.role) === "admin";
|
2275
2276
|
}
|
2277
|
+
|
2278
|
+
// src/login.js
|
2279
|
+
async function signInWithEmail(email, password) {
|
2280
|
+
try {
|
2281
|
+
const { data: session, error } = await supabase.auth.signInWithPassword({
|
2282
|
+
email,
|
2283
|
+
password
|
2284
|
+
});
|
2285
|
+
return { session, error };
|
2286
|
+
} catch (err) {
|
2287
|
+
console.error("Unexpected error during login:", err);
|
2288
|
+
return { session: null, error: err };
|
2289
|
+
}
|
2290
|
+
}
|
2276
2291
|
// Annotate the CommonJS export names for ESM import in node:
|
2277
2292
|
0 && (module.exports = {
|
2278
2293
|
AuthWrapper,
|
2279
2294
|
LogoutButton,
|
2280
2295
|
isAdmin,
|
2296
|
+
signInWithEmail,
|
2281
2297
|
supabase,
|
2282
2298
|
useAuth
|
2283
2299
|
});
|
package/dist/index.mjs
CHANGED
@@ -2257,10 +2257,25 @@ function LogoutButton({ supabaseClient, onLogout }) {
|
|
2257
2257
|
function isAdmin(user) {
|
2258
2258
|
return (user == null ? void 0 : user.role) === "admin";
|
2259
2259
|
}
|
2260
|
+
|
2261
|
+
// src/login.js
|
2262
|
+
async function signInWithEmail(email, password) {
|
2263
|
+
try {
|
2264
|
+
const { data: session, error } = await supabase.auth.signInWithPassword({
|
2265
|
+
email,
|
2266
|
+
password
|
2267
|
+
});
|
2268
|
+
return { session, error };
|
2269
|
+
} catch (err) {
|
2270
|
+
console.error("Unexpected error during login:", err);
|
2271
|
+
return { session: null, error: err };
|
2272
|
+
}
|
2273
|
+
}
|
2260
2274
|
export {
|
2261
2275
|
AuthWrapper,
|
2262
2276
|
LogoutButton,
|
2263
2277
|
isAdmin,
|
2278
|
+
signInWithEmail,
|
2264
2279
|
supabase,
|
2265
2280
|
useAuth
|
2266
2281
|
};
|
package/index.d.ts
ADDED
package/package.json
CHANGED
package/src/index.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
export { default as AuthWrapper } from './AuthWrapper'
|
2
|
-
export { default as LogoutButton } from './LogoutButton'
|
3
|
-
export { useAuth } from './useAuth'
|
4
|
-
export { isAdmin } from './utils'
|
5
|
-
export { supabase } from './supabaseClient'
|
1
|
+
export { default as AuthWrapper } from './AuthWrapper';
|
2
|
+
export { default as LogoutButton } from './LogoutButton';
|
3
|
+
export { useAuth } from './useAuth';
|
4
|
+
export { isAdmin } from './utils';
|
5
|
+
export { supabase } from './supabaseClient';
|
6
|
+
export { signInWithEmail } from './login'; // Add this line
|
package/src/login.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import { supabase } from './supabaseClient';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Logs in a user using email and password.
|
5
|
+
* @param {string} email - The user's email address.
|
6
|
+
* @param {string} password - The user's password.
|
7
|
+
* @returns {Promise<{ session: any, error: any }>} - The session and error (if any).
|
8
|
+
*/
|
9
|
+
export async function signInWithEmail(email, password) {
|
10
|
+
try {
|
11
|
+
const { data: session, error } = await supabase.auth.signInWithPassword({
|
12
|
+
email,
|
13
|
+
password,
|
14
|
+
});
|
15
|
+
|
16
|
+
return { session, error };
|
17
|
+
} catch (err) {
|
18
|
+
console.error('Unexpected error during login:', err);
|
19
|
+
return { session: null, error: err };
|
20
|
+
}
|
21
|
+
}
|