fix creation/auth process
This commit is contained in:
@@ -11,6 +11,8 @@ apx.apxauth.loadwco = async (id, ctx) => {
|
||||
ctx
|
||||
)}`
|
||||
);
|
||||
// Check that in localdb tpl exist if not means it is not authenticated
|
||||
if (!apx.data.tpl[`apxauthscreen${ctx.link}`]) ctx.link="signin";
|
||||
const tpldataname = `${apx.data.pagename}_${id}_apxauth`;
|
||||
const apxauthid = document.getElementById(id);
|
||||
const data = apx.apxauth.getdata(id, ctx);
|
||||
@@ -31,7 +33,7 @@ apx.apxauth.getdata = (id, ctx) => {
|
||||
data.xalias = apx.data.headers.xalias;
|
||||
data.xtribe = apx.data.headers.xtribe;
|
||||
|
||||
data.emailssuport = apx.data.appdata.emailsupport
|
||||
data.emailssuport = apx.data?.appdata?.emailsupport
|
||||
? apx.data.appdata.emailsupport
|
||||
: "";
|
||||
switch (ctx.link) {
|
||||
@@ -44,7 +46,7 @@ apx.apxauth.getdata = (id, ctx) => {
|
||||
});
|
||||
data.noprofils = data.profils.length == 0;
|
||||
data.member = apx.data.headers.xprofils.includes("persons");
|
||||
data.websites = apx.data.appdata.websites;
|
||||
data.websites = apx.data?.appdata?.websites || [];
|
||||
data.optionlinks=apx.data.tpldata[tpldataname].optionlinks
|
||||
data.town=apx.data.town
|
||||
data.nation=apx.data.nation
|
||||
@@ -52,10 +54,13 @@ apx.apxauth.getdata = (id, ctx) => {
|
||||
apx.data.tpldata[tpldataname].optionlinksmajor.forEach(o=>data.optionlinks.push(o))
|
||||
apx.save()
|
||||
}
|
||||
if (!apx.data.itms) apx.data.itms={}
|
||||
if (!apx.data.wco) apx.data.wco={}
|
||||
|
||||
// get towns list
|
||||
axios
|
||||
.get(`/api/apxtri/odmdb/idx/apxtri/towns/towns`, {
|
||||
headers: apx.data.headers,
|
||||
headers: apx.data.headers, withCredentials:true
|
||||
})
|
||||
.then((rep) => {
|
||||
console.log(rep)
|
||||
@@ -72,7 +77,7 @@ apx.apxauth.getdata = (id, ctx) => {
|
||||
});
|
||||
axios
|
||||
.get(`/api/apxtri/odmdb/idx/apxtri/pagans/lst_alias`, {
|
||||
headers: apx.data.headers,
|
||||
headers: apx.data.headers, withCredentials:true
|
||||
})
|
||||
.then((rep) => {
|
||||
if (rep.status==200){
|
||||
@@ -139,7 +144,7 @@ apx.apxauth.redirecturlwithauth = (
|
||||
apx.apxauth.logout = () => {
|
||||
axios
|
||||
.get(`/api/apxtri/pagans/logout`, {
|
||||
headers: apx.data.headers,
|
||||
headers: apx.data.headers, withCredentials:true
|
||||
})
|
||||
.then((rep) => {
|
||||
console.log("logout", rep);
|
||||
@@ -250,7 +255,7 @@ apx.apxauth.authentifyme = async (
|
||||
console.log(`get /api/apxtri/pagans/alias/${alias}`);
|
||||
axios
|
||||
.get(`/api/apxtri/pagans/alias/${alias}`, {
|
||||
headers: apx.data.headers,
|
||||
headers: apx.data.headers, withCredentials:true
|
||||
})
|
||||
.then(async (rep) => {
|
||||
//console.log(rep.data);
|
||||
@@ -358,7 +363,7 @@ apx.apxauth.recoverykey = (id, aliasoremail) => {
|
||||
document.querySelector(`#${id} .msginfo`).innerHTML = "";
|
||||
axios
|
||||
.post(`/api/apxtri/pagans/keyrecovery`, recodata, {
|
||||
headers: apx.data.headers,
|
||||
headers: apx.data.headers
|
||||
})
|
||||
.then((rep) => {
|
||||
rep.data.data.search = aliasoremail;
|
||||
@@ -678,15 +683,14 @@ apx.apxauth.registerIdentity = async (id, trustedtribe) => {
|
||||
data.trustedtribe = trustedtribe;
|
||||
console.log(data)
|
||||
axios
|
||||
.post(`/api/apxtri/pagans`, data, { headers: apx.data.headers })
|
||||
.post(`/api/apxtri/pagans`, data, { headers: apx.data.headers, withCredentials:true})
|
||||
.then((reppagan) => {
|
||||
//console.log(reppagan.data);
|
||||
apx.notification(`#${id} .msginfo`, reppagan.data);
|
||||
authid.querySelector(`.btncreateidentity`).classList.add("hidden");
|
||||
authid.querySelector(`.signupbtnreload`).classList.remove("hidden");
|
||||
//remove tmp cause create phc change to keep tplauth in memory and avoid asking again the pasword
|
||||
//delete apx.data.tmpauth;
|
||||
//apx.save();
|
||||
apx.data.headers.xprofils=reppagan.data.profils;
|
||||
apx.data.save();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("error:", err);
|
||||
@@ -713,13 +717,13 @@ apx.apxauth.jointribe = (id) => {
|
||||
};
|
||||
axios
|
||||
.put(`/api/apxtri/pagans/person/${apx.data.headers.xtribe}`, data, {
|
||||
headers: apx.data.headers,
|
||||
headers: apx.data.headers, withCredentials:true
|
||||
})
|
||||
.then((rep) => {
|
||||
apx.notification(`#${id} .msginfo`, rep.data);
|
||||
axios
|
||||
.get(`/api/apxtri/pagans/logout`, {
|
||||
headers: apx.data.headers,
|
||||
headers: apx.data.headers, withCredentials:true
|
||||
})
|
||||
.then((rep) => {
|
||||
console.log("logout", rep);
|
||||
|
Reference in New Issue
Block a user