wei 🌲 is 🌴 fe 🌳 Mar 12 🎋 2020
note: those assumptions don't hold all the time
not customizable
all integrating with DL's back end
fully customizable
window.fallbackFunctions
it's kind of empty in middle, we don't want to make false assumptions about what kind of abstractions we want
supported PATH_PREFIX
supported api endpoints
added skipAuth
adding...?
// kaya toast core App component
import { Authenticate } from '@shopee/toastack-auth'; // or other names
// other imports omitted
const App = ({children, siteConfig}) => {
return (
<Authenticate
pathPrefix="/api/v1"
endpoints={{
login: '/auth/info',
logout: '/auth/logout',
}}
fallbackFunctions={/* omitted */}
transferData={({ user }) => ({ loginInfo: user })}
>
<SiteContextProvider siteConfig={siteConfig}>
{children}
</SiteContextProvider>
</Authenticate>
)
}
// page
import { EnsureLoggedIn } from '@shopee/toastack-auth'; // or other names
const PageUI = ({ greeting }) => <div>hello! {greeting}</div>;
const PageRequiresLogin = props => (
<EnsureLoggedIn
UILoading={<Spin />}
UINotLoggedIn={<svg />}
>
<PageUI />
</EnsureLoggedIn />
);
export default PageRequiresLogin;
// widget
import { EnsureLoggedIn } from '@shopee/toastack-auth';
import { SideNav } from '@shopee/kaya-toast';
const SideNav = (props) => (
<EnsureLoggedIn>
<SideNav {...props} />
</EnsureLoggedIn>
);
not customizable
all integrating with DL's back end
fully customizable
window.fallbackFunctions
opinionatedly customizable