lx-login
v0.2.0
Published
Login/register component
Downloads
75
Readme
lx-login
Login/register component
install
npm i lx-login
usage
component
import LoginView from "lx-login";
const register = {
post: "https://localhost/api/register",
redirect: "https://localhost/app/login",
callback: ({ success }) => console.log("register", success),
};
const login = {
post: "https://localhost/api/login",
redirect: "https://localhost/app?token={{token}}",
callback: ({ token }) => console.log("login", token),
model: ([email, password]) => ({
email,
password,
deviceId: 123,
}),
};
const App = () => <LoginView register={register} login={login} />;
post
Payload from form will post to this url.
redirect
Redirects to url after post. Keywords in {{brackets}} will be replaced with response from post url.
login.model([email,password])
register.model([firstName,lastName,email,password])Modifies the payload from the form before posting to post url.
callback(data)
Called with response from post url.
themed
import LoginView from "lx-login";
import { Theme, themes } from "lx-theme";
const register = {
post: "https://localhost/api/register",
redirect: "https://localhost/app/login",
};
const login = {
post: "https://localhost/api/login",
redirect: "https://localhost/app?key={{token}}",
};
const App = () => (
<Theme theme={themes["CODING"]}>
<LoginView register={register} login={login} />
</Theme>
);
standalone
git switch -c new-branch
sudo apt-get update
sudo apt install docker.io
sudo snap install docker
sudo docker build -t login-app ./
sudo docker run -p 3000:3000 login-app
const server = "https://localhost:3000/";
const register = {
post: "https://localhost/api/register",
redirect: "https://localhost/app/login",
};
const login = {
post: "https://localhost/api/login",
redirect: encodeURIComponent("https://localhost/app?key={{token}}"),
};
const theme = "CODING";
const url = `http://${server}/?login.post=${login.post}®ister.post=${register.post}&login.redirect=${login.redirect}&theme=${theme}`;