-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'javad-zobeidi-dev' into dev
- Loading branch information
Showing
13 changed files
with
177 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:eloquent/eloquent.dart'; | ||
import 'package:vania/src/exception/http_exception.dart'; | ||
|
||
extension DatabaseHelper on QueryBuilder { | ||
// Create and return inserted data | ||
Future<Map<String, dynamic>> create(Map<String, dynamic> data) async { | ||
final insertId = await insertGetId(data); | ||
final record = await where('id', '=', insertId).first(); | ||
return record ?? {}; | ||
} | ||
|
||
// Insert many data in the table | ||
Future<bool> insertMany(List<Map<String, dynamic>> data) async { | ||
for (Map<String, dynamic> row in data) { | ||
try { | ||
await insert(row); | ||
} on QueryException catch (e) { | ||
throw HttpResponseException( | ||
message: e.sql, | ||
code: HttpStatus.internalServerError, | ||
); | ||
} | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
APP_KEY='kQ1spu2E1r452fLa7cSihi7p1pdBR7040H8-UxtXNXg8=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:vania/vania.dart'; | ||
|
||
void main() { | ||
group('Hash class test', () { | ||
setUp(() { | ||
Env().load(file: File('test/.env')); | ||
}); | ||
|
||
test('Make/Verify correct paswword', () { | ||
String password = "123456789"; | ||
String hash = Hash().make(password); | ||
expect(Hash().verify(password, hash), true); | ||
}); | ||
|
||
test('Make/Verify wrong password', () { | ||
String password = "123456789"; | ||
String hash = Hash().make(password); | ||
expect(Hash().verify("12345678", hash), false); | ||
}); | ||
}); | ||
} |