@iotechpis/ioaccount
v2.2.0
Published
```` npm i @iotechpis/ioaccount -s ````
Downloads
4
Readme
npm-iotechpis_ioaccount
Install
npm i @iotechpis/ioaccount -s
How to use
Init
//Mongo connection for ioTokens DB
const mongodb_connection = "mongodb://username:[email protected]:27017/db";
//URL for ioaccount API
const ioaccount_api = "https://ioaccountapi.com";
const current_app_id = 78345673457;
const token_expiration_time = 15000; //in sec
require("@iotechpis/ioaccount").init(mongodb_connection, ioaccount_api, current_app_id, token_expiration_time, callback);
auth
.login(email, password, callback)
let email = "[email protected]";
let password = "12345";
require("@iotechpis/ioaccount").auth.login(email, password, (error, data) => {
//data = {headers, body};
});
.logout(token, callback)
let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";
require("@iotechpis/ioaccount").auth.logout(token, () => {
});
.info(token, callback)
let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";
require("@iotechpis/ioaccount").auth.info(token, (error, data) => {
//data = {headers, body};
});
.recoverPasswordRequest(email, callback)
let email = "[email protected]";
require("@iotechpis/ioaccount").auth.recoverPasswordRequest(email, (error, data) => {
//data = {headers, body};
});
tokens
.create(payload, callback)
let payload = {
user_id: "1", //only this field is obligatory, the others can be whatever you want
};
require("@iotechpis/ioaccount").tokens.create(payload, (token) => {
});
.delete(token, callback)
let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";
require("@iotechpis/ioaccount").tokens.delete(token, () => {
});
.validate(token, callback)
let token= "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVDJ9.eyJpZCI6ImNmN2FmODNiZDE0Yjk4Zjg5NTgyOTkzYjljMmQxZDQ1OGQxMTA1NGI0NGU1MGIxM2E5Y3FiOGM4ODJhNTQ0OTc2NWUxMWQ3NTk1YzRlNjI4IiwidHlwZSI6IkNvbXBhbnkiLCJp1vB537z3wuE_ph_kJ9-5kuxgaPcjYk4txYm1s";
require("@iotechpis/ioaccount").tokens.validate(token, (error, token, payload) => {
});
user
.register(email, password, confirm_password, callback)
let email = "[email protected]";
require("@iotechpis/ioaccount").user.register(email, (error, data) => {
//data = {headers, body};
});
.registerMany(users, callback)
let users = [
{
"email": "[email protected]"
}, ...
];
require("@iotechpis/ioaccount").user.registerMany(users, (error, data) => {
//data = {headers, body};
});
.getByIds(users, callback)
let ids = [
"rgjregjenrg",
"rwjegnregn"
];
require("@iotechpis/ioaccount").user.getByIds(ids, (error, data) => {
//data = {headers, body};
});