{"size": 1653, "ext": "js", "max_stars_repo_path": "Movies/Templates/scripts/auth.js", "max_stars_repo_name": "edgonzalezdi/TheFoundation", "max_stars_repo_stars_event_min_datetime": "2022-01-05T19:15:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-05T19:15:55.000Z", "max_issues_repo_path": "Movies/Templates/scripts/auth.js", "max_issues_repo_name": "edgonzalezdi/TheFoundation", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Movies/Templates/scripts/auth.js", "max_forks_repo_name": "edgonzalezdi/TheFoundation", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 40.3170731707, "max_line_length": 74, "alphanum_fraction": 0.4978826376}
(function (window,undefined) {
    var auth0 = null;
    const writeStatus = (data) => {
        document.getElementById("status").innerHTML = data;
    }

    window.addEventListener("load",async () => {
            auth0 = (await Utilities.configureAuth());
            
            await auth0.checkSession();
            writeStatus("Verificando si estas autenticado....");
            let authenticated = await auth0.isAuthenticated();
            if(authenticated){
                writeStatus("Bienvenido de nuevo!");
                window.location.replace("http://localhost:3000/menu");
            }else{
                writeStatus("Revisando el estado de su solicitud...");
                let query = window.location.search;
                if(query.includes("code=") && query.includes("state=")){
                writeStatus("Recibiendo info de logueo...");
                try{
                    let result = await auth0.handleRedirectCallback();
                    writeStatus("Logueado exitosamente!");
                    let user = await auth0.getUser();
                    writeStatus("Bienvenido "+user.name);
                    window.location.replace("http://localhost:3000/menu");
                }catch(e){
                    writeStatus(e);
                    window.location.replace("http://localhost:3000");
                }
                
                
            }else{
                writeStatus("Se te redirigirá pronto..");
                await auth0.loginWithRedirect({
                    redirect_uri: "http://localhost:3000/login"
                });
            }
        }
    },false);
})(window);