diff --git a/adminapi/www/adminapx/static/tpl/pagancreate_en.mustache b/adminapi/www/adminapx/static/tpl/pagancreate_en.mustache index 0d3703d..72dd132 100644 --- a/adminapi/www/adminapx/static/tpl/pagancreate_en.mustache +++ b/adminapi/www/adminapx/static/tpl/pagancreate_en.mustache @@ -73,8 +73,7 @@

Logout

-

I prove that i own this alias

@@ -89,7 +88,8 @@ + onclick="pagans.authentifyme(document.getElementById('inputaliasauth').value,document.getElementById('inputpassphraseauth').value,document.getElementById('privatekeyauth').value);alert('Click on Test it to check')">Sign + my header

Create a decentralized Identity

apXtrib allow you to create keys to identify yourself with a universal alias

@@ -148,10 +148,10 @@

Download your keys at least PrivateKey this have to save in a secret place

diff --git a/adminapi/www/adminapx/static/tpl/paganloginoutASUP_en.mustache b/adminapi/www/adminapx/static/tpl/paganloginoutASUP_en.mustache deleted file mode 100644 index 6187217..0000000 --- a/adminapi/www/adminapx/static/tpl/paganloginoutASUP_en.mustache +++ /dev/null @@ -1,23 +0,0 @@ -
-
How to identify ourself
-

You need to know your alias and to have your privateKey file

-
- - -
Your unique alias when you create your account
-
-
- - - -
-
- - -
-
- - -
- -
\ No newline at end of file diff --git a/api/models/Pagans.js b/api/models/Pagans.js index df5a3f9..8410cca 100644 --- a/api/models/Pagans.js +++ b/api/models/Pagans.js @@ -19,6 +19,50 @@ const conf = require(`${process.env.dirtown}/conf.json`); const Pagans = {}; +Pagans.getalias = (alias) => { + console.log(`${conf.dirapi}/nationchains/pagans/itm/${alias}.json`); + if (fs.existsSync(`${conf.dirapi}/nationchains/pagans/itm/${alias}.json`)) { + return { + status: 200, + ref: "Pagans", + msg: "aliasexist", + data: fs.readJsonSync( + `${conf.dirapi}/nationchains/pagans/itm/${alias}.json` + ), + }; + } else { + return { + status: 404, + ref: "Pagans", + msg: "aliasdoesnotexist", + data: { alias }, + }; + } +}; + +Pagans.getperson = (alias, tribeid) => { + if ( + fs.existsSync(`${conf.dirtown}/tribes/${tribeid}/person/itm/${alias}.json`) + ) { + const person = fs.readJsonSync( + `${conf.dirtown}/tribes/${tribeid}/person/itm/${alias}.json` + ); + return { + status: 200, + ref: "Pagans", + msg: "personexist", + data: person, + }; + } else { + return { + status: 404, + ref: "Pagans", + msg: "persondoesnotexist", + data: { alias, tribeid }, + }; + } +}; + Pagans.create = (alias, publicKey) => { /** * @param {string} alias a unique alias that identify an identity diff --git a/api/routes/pagans.js b/api/routes/pagans.js index f28ef89..6c53d6c 100755 --- a/api/routes/pagans.js +++ b/api/routes/pagans.js @@ -47,6 +47,15 @@ Delete idem Owner means it can be Write/Delete if field OWNER contain the UUID that try to act on this object. Usefull to allow someone to fully manage its objects. */ +router.get("/alias/:alias", (req, res) => { + res.send(Pagans.getalias(req.params.alias)); +}); +router.get("/person/:alias", (req, res) => { + // check accessright for req.session.header.xalias to see if jhe can get person data + // if req.param.alias == req.session.header.xalias => Owner + // else need accessright to on person set at R + res.send(Pagans.getperson(req.params.alias, req.session.header.xtribe)); +}); router.get("/isauth", checkHeaders, isAuthenticated, (req, res) => { /** diff --git a/apxtrib.js b/apxtrib.js index 5e2a1fe..188a6e1 100755 --- a/apxtrib.js +++ b/apxtrib.js @@ -180,15 +180,24 @@ if ( ) { setconf(param); } -// From git setup-xx is set to nationId:ant townId:farmdev (keyword for dev) -let infotown = {nationId:"ants",townId:"devfarm",dns:["devfarm-ants"],comment:"Auto generate setup from apxtrib after node apxtrib nationId:value townId:value dns:domaine_to_access"} -if (fs.existsSync(`${__dirname}/adminapi/www/adminapx/conf/setup_xx.json`)){ - infotown = fs.readJsonSync( - `${__dirname}/adminapi/www/adminapx/conf/setup_xx.json` -); - }else{ - fs.outputJsonSync(`${__dirname}/adminapi/www/adminapx/conf/setup_xx.json`,infotown); - } +// setup_xx.json is gitignore so at first install we are in dev configuration +let infotown = { + nationId: "ants", + townId: "devfarm", + dns: ["devfarm-ants"], + comment: + "Auto generate setup from apxtrib after node apxtrib nationId:value townId:value dns:domaine_to_access", +}; +if (fs.existsSync(`${__dirname}/adminapi/www/adminapx/conf/setup_xx.json`)) { + infotown = fs.readJsonSync( + `${__dirname}/adminapi/www/adminapx/conf/setup_xx.json` + ); +} else { + fs.outputJsonSync( + `${__dirname}/adminapi/www/adminapx/conf/setup_xx.json`, + infotown + ); +} if ( !fs.existsSync( @@ -198,7 +207,7 @@ if ( ) || !fs.existsSync(`${__dirname}/adminapi/www/nginx_adminapx.conf`) ) { - // Run setup with information setup_xx.json + // Case of new town or request a reset of dns to access adminapx setconf(infotown); } const conf = require(path.resolve(