Skip to content
This repository has been archived by the owner on Aug 21, 2018. It is now read-only.

remove default admin from install #1060

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 17 additions & 49 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -73,59 +73,27 @@ function installDesignDocs() {
installDesignDocs()
}
} else {
createDefaultAdminMember()
insertConfigurationDoc()
}
}

function createDefaultAdminMember() {
nano.db.get('members', function(err, body) {
if (err) console.log(err)
// Cancel if there are already members in the database
if (body.doc_count > 1) return done()
console.log('Creating a default admin member of admin:password')
var members = nano.db.use('members')
var defaultAdminMember = {
"login": "admin",
"kind": "Member",
"roles": ["Manager", "SuperManager"],
"firstName": "Default",
"lastName": "Admin",
"password": "password",
"Gender": "Male",
"status": "active",
"email": "[email protected]",
"visits": 0
}
var configurationsDoc = {
"name": "olesomalia",
"nationName": "olenation",
"code": "so",
"type": "nation",
"nationUrl": "olenation.cloudant.com",
"version": "0.10.0",
"notes": "this is testing .....asdf",
"currentLanguage": "English"
};
members.insert(defaultAdminMember, function(err, res) {
if (err)
return console.log(err)
else {
var configurations = nano.db.use('configurations');
configurations.insert(configurationsDoc, function(err, res) {
if (err) {
console.log(err);
} else {
var languages = nano.db.use('languages');
console.log("******************Going to insert document into languages database*******************************");
insertLanguageDocs();
}
});
}

done()
})
})
function insertConfigurationDoc() {
var configurations = nano.db.use('configurations');
var confDocPath = './init_docs/ConfigurationsDoc-Nation.txt';
fs.readFile(confDocPath, function (err, data) {
configurations.insert(data, function (err, res) {
if (err) {
console.log(err);
} else {
console.log("configuration doc inserted successfully.");
console.log("******************Going to insert document into languages database*******************************");
insertLanguageDocs();
}
done()
});
});
}

function insertLanguageDocs() {
var languages = nano.db.use('languages');
fs.readdir('./init_docs/languages', function doneReadDir(err, files) {
Expand Down
19 changes: 18 additions & 1 deletion install_windows
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function installDesignDocs() {
installDesignDocs()
}
} else {
createDefaultAdminMember()
insertConfigurationDoc()
}
}

Expand Down Expand Up @@ -112,6 +112,23 @@ function createDefaultAdminMember() {
});
}

function insertConfigurationDoc() {
var configurations = nano.db.use('configurations');
var confDocPath = './init_docs/ConfigurationsDoc-Nation.txt';
fs.readFile(confDocPath, function (err, data) {
configurations.insert(data, function (err, res) {
if (err) {
console.log(err);
} else {
console.log("configuration doc inserted successfully.");
console.log("******************Going to insert document into languages database*******************************");
insertLanguageDocs();
}
done()
});
});
}

function insertLanguageDocs() {
var languages = nano.db.use('languages');
fs.readdir('./init_docs/languages', function doneReadDir(err, files) {
Expand Down