aboutsummaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
Diffstat (limited to 'providers')
-rw-r--r--providers/AppProvider.ts21
-rw-r--r--providers/LegacyHashDriver.ts19
-rw-r--r--providers/LegacyHasherProvider.ts14
3 files changed, 54 insertions, 0 deletions
diff --git a/providers/AppProvider.ts b/providers/AppProvider.ts
new file mode 100644
index 0000000..8d64412
--- /dev/null
+++ b/providers/AppProvider.ts
@@ -0,0 +1,21 @@
1import { ApplicationContract } from '@ioc:Adonis/Core/Application';
2
3export default class AppProvider {
4 constructor(protected app: ApplicationContract) {}
5
6 public register() {
7 // Register your own bindings
8 }
9
10 public async boot() {
11 // IoC container is ready
12 }
13
14 public async ready() {
15 // App is ready
16 }
17
18 public async shutdown() {
19 // Cleanup, since app is going down
20 }
21}
diff --git a/providers/LegacyHashDriver.ts b/providers/LegacyHashDriver.ts
new file mode 100644
index 0000000..22f9de1
--- /dev/null
+++ b/providers/LegacyHashDriver.ts
@@ -0,0 +1,19 @@
1import bcrypt from 'bcrypt';
2import { HashDriverContract } from '@ioc:Adonis/Core/Hash';
3/**
4 * Implementation of custom bcrypt driver
5 */
6export class LegacyHashDriver implements HashDriverContract {
7 /**
8 * Hash value
9 */
10 public async make(value: string) {
11 return bcrypt.hash(value, 10);
12 }
13 /**
14 * Verify value
15 */
16 public async verify(hashedValue: string, plainValue: string) {
17 return bcrypt.compare(plainValue, hashedValue);
18 }
19}
diff --git a/providers/LegacyHasherProvider.ts b/providers/LegacyHasherProvider.ts
new file mode 100644
index 0000000..05b2d27
--- /dev/null
+++ b/providers/LegacyHasherProvider.ts
@@ -0,0 +1,14 @@
1import { ApplicationContract } from '@ioc:Adonis/Core/Application';
2import { LegacyHashDriver } from './LegacyHashDriver';
3
4export default class LegacyHasherProvider {
5 constructor(protected app: ApplicationContract) {}
6
7 public async boot() {
8 const Hash = this.app.container.use('Adonis/Core/Hash');
9
10 Hash.extend('legacy', () => {
11 return new LegacyHashDriver();
12 });
13 }
14}