forked from geolba/tethys.backend
- add methods for releasing datasets from submitter
- npm updates - side menu with child items - flash messages via HttpContext response (extended via macro)
This commit is contained in:
parent
e0ff71b117
commit
f403c3109f
37 changed files with 1020 additions and 482 deletions
|
@ -1,5 +1,7 @@
|
|||
import type { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
||||
import Hash from '@ioc:Adonis/Core/Hash';
|
||||
import type Hash from '@ioc:Adonis/Core/Hash';
|
||||
// import HttpContextContract from '@ioc:Adonis/Core/HttpContext';
|
||||
import type Response from '@ioc:Adonis/Core/Response';
|
||||
import { LaravelHash } from './HashDriver';
|
||||
|
||||
export default class AppProvider {
|
||||
|
@ -15,6 +17,22 @@ export default class AppProvider {
|
|||
hashInstance.extend('bcrypt', () => {
|
||||
return new LaravelHash();
|
||||
});
|
||||
|
||||
const responseInstance: typeof Response = this.app.container.use('Adonis/Core/Response');
|
||||
responseInstance.macro('flash', function (key: string, message: any) {
|
||||
this.ctx!.session.flash(key, message);
|
||||
return this;
|
||||
});
|
||||
responseInstance.macro('toRoute', function (route: string) {
|
||||
this.redirect().toRoute(route);
|
||||
return this;
|
||||
});
|
||||
// this.app.container.singleton('Adonis/Core/Response', () => {
|
||||
// return FlashResponse;
|
||||
// });
|
||||
|
||||
// this.app.container.singleton('Adonis/Core/HttpContext', () => {
|
||||
// });
|
||||
}
|
||||
|
||||
public async ready() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { HashDriverContract } from "@ioc:Adonis/Core/Hash";
|
||||
import { HashDriverContract } from '@ioc:Adonis/Core/Hash';
|
||||
// const bcrypt = require("bcrypt");
|
||||
import bcrypt from "bcryptjs";
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
const saltRounds = 10;
|
||||
export class LaravelHash implements HashDriverContract {
|
||||
|
@ -11,11 +11,11 @@ export class LaravelHash implements HashDriverContract {
|
|||
|
||||
public async verify(hashedValue: string, plainValue: string) {
|
||||
let newHash: string;
|
||||
if (hashedValue.includes("$2y$10$")) {
|
||||
newHash = hashedValue.replace("$2y$10$", "$2a$10$");
|
||||
if (hashedValue.includes('$2y$10$')) {
|
||||
newHash = hashedValue.replace('$2y$10$', '$2a$10$');
|
||||
} else {
|
||||
newHash = hashedValue;
|
||||
}
|
||||
return await bcrypt.compareSync(plainValue, newHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue