mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-24 07:39:42 +02:00
Password from env variable (#170)
* rm: remove the generate password file * rm: commander package * rm: remove the password reading from db * feat: password hash reading from env added * passHash replace with password * raw password comparison added * rm: user model and controller removed * update: auth route and token verification * replace multiple dotenv config with one * .env.sample added with updated docker yml * rm:remove the bcrypt * readme updated with .env * remove generatePassword from package json * updated docs * removed the console.log
This commit is contained in:
parent
aaf2644ed4
commit
303d670c49
13 changed files with 53 additions and 359 deletions
|
@ -1,40 +0,0 @@
|
|||
import database from '../utils/database/index';
|
||||
|
||||
const db = database['password'];
|
||||
|
||||
export interface UserData {
|
||||
passHash?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class User
|
||||
* @class User model
|
||||
*
|
||||
* @property {string} passHash - hashed password
|
||||
*/
|
||||
class User {
|
||||
public passHash?: string;
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @param {UserData} userData - user data for construct new object
|
||||
*/
|
||||
constructor(userData: UserData) {
|
||||
this.passHash = userData.passHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find and return model of user.
|
||||
* User is only one.
|
||||
*
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
public static async get(): Promise<User> {
|
||||
const userData: UserData = await db.findOne({});
|
||||
|
||||
return new User(userData);
|
||||
}
|
||||
}
|
||||
|
||||
export default User;
|
Loading…
Add table
Add a link
Reference in a new issue