Code | Message | How to debug / fix |
---|---|---|
PasswordMismatch | You entered a wrong password! | Did you store password we hashed for you? |
UsernameRequired | Username is required field, please enter the username! | :thinking: |
PasswordRequired | Password is required field, please enter the password! | :thinking: |
UserNotFound | It seems this user doesn't exist, are you sure you entered correct credentials? | Do you want to enable auto registration? Declare saveNonExistingUser function |
Under heavy development
import { createAuthenticator } from 'authist';
const authenticator = createAuthenticator({
getUserById: () => Promise.resolve(), // todo: add implementation
emailPassword: {
getUserByEmail: (email: string) => Promise.resolve(), // todo: add implementation
},
});
const { user, credentials } = await authenticator.signInWithEmailAndPassword(email, password);
import express from 'express';
const app = express();
app.get('/users/me', authenticator.expressBearer, (req, res) => {
res.json(req.user);
});
signInWithFacebook
method takes token
parameter that is Facebook access token you will get it on the frontend sideemail
permission assigned to successfully get the user's emailimport { createAuthenticator } from 'authist';
const authenticator = createAuthenticator({
getUserById: () => Promise.resolve(), // todo: add implementation
facebook: {
getUserByEmail: (email: string) => Promise.resolve(), // todo: add implementation
graphApiVersion: 'v9.0',
},
});
const { user, credentials } = await authenticator.signInWithFacebook(accessToken);
signInWithGoogle
method takes token
parameter that is Google access tokenemail
scope assigned to successfully get the user's emailimport { createAuthenticator } from 'authist';
const authenticator = createAuthenticator({
getUserById: () => Promise.resolve(), // todo: add implementation
google: {
getUserByEmail: (email: string) => Promise.resolve(), // todo: add implementation
},
});
const { user, credentials } = await authenticator.signInWithGoogle(accessToken);
This project is licensed under MIT.
Generated using TypeDoc