1.0.9 • Published 6 years ago

clientside-view-modal-login_signup v1.0.9

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

clientside-view-modal-login_signup

    load("clientside-view-loader")
        .then(view=>view.load("clientside-view-modal-login_signup").build());
        .then((modal)=>{
            document.body.appendChild(modal);
            modal.show("login");
        })

generates a fully functional one of these:

screenshot_2018-02-10_15-42-31

with which you can do things like this:

.then((modal)=>{
    document.querySelector("#signup_button").onclick = ()=>{modal.handler.show("signup")}
    document.querySelector("#loginup_button").onclick = ()=>{modal.handler.show("login")}
    modal.submission_button.signup.onclick = function(){
        require("clientside-controller-user_sessions")
            .then((controller)=>{
                return controller.signin("signup", {
                    email : modal.extract.email(),
                    password : modal.extract.password(),
                })
            })
            .then((response)=>{
                alert("Success!");
                modal.submission_button.login.onclick(); // after signup automatically sign user in
            })
    }
    modal.submission_button.login.onclick = function(){
        require("clientside-controller-user_sessions")
            .then((controller)=>{
                return controller.signin("login", {
                    email : modal.extract.email(),
                    password : modal.extract.password(),
                })
            })
            .then((response)=>{
                if(response == "SCS"){
                    window.location.href = "/my/dashboard";
                } else {
                    console.error("Response for login was not expected: " + response)
                    alert("An unknown error has occured.");
                }
            })
    }
})