0.2.0 • Published 2 years ago

lx-login v0.2.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

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}&register.post=${register.post}&login.redirect=${login.redirect}&theme=${theme}`;
0.1.10

2 years ago

0.1.11

2 years ago

0.2.0

2 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago