Skip to content

Commit

Permalink
Show error if password is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
jayralencar committed Apr 23, 2016
1 parent 750b28c commit 76a5739
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log
This change log is started in 0.3.2;

## 0.3.2 (2016-04-23)
- Show error if password is invalid
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"encrypt",
"decrypt"
],
"version": "0.3.1",
"version": "0.3.2",
"author": {
"name": "Jayr Alencar",
"email": "jayralencarpereira@gmail.com",
Expand Down
6 changes: 6 additions & 0 deletions sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ sqlite.prototype.connect = function(db, password, algorithm){
this.con(1);
}

try{
this.run("SELECT name FROM sqlite_master WHERE type = 'table'");
}catch(e){
throw "Invalid Password! Please check your password or database name.";
}

return this;
}

Expand Down
8 changes: 6 additions & 2 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ var sqlite = require('../sqlite.js'); //requiring
sqlite.iv = '13ewr3iJ';

//Connecting - (databaseFile, [password], [algorithm])
sqlite.connect('test/Database.rec','myPass','aes-256-ctr');
try{
sqlite.connect('test/Database.rec','myPass','aes-256-ctr');
}catch(x){
console.log(x)
}

//Creating Table - you can run any command
// Creating Table - you can run any command
sqlite.run("CREATE TABLE COMPANYS(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL);");

//Inserting - this function can be sync to, look the wiki
Expand Down

0 comments on commit 76a5739

Please sign in to comment.