Skip to content

Commit

Permalink
DEV - add default admin user in db + clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
juliecoust committed Jan 30, 2024
1 parent 770949b commit f3f7115
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/data/data-sources/sqlite/sqlite-user-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ export class SQLiteUserDataSource implements UserDataSource {
}

init_user_db() {
// Create table if not exist
const sql_create = "CREATE TABLE IF NOT EXISTS 'user' (user_id INTEGER PRIMARY KEY AUTOINCREMENT, first_name TEXT NOT NULL, last_name TEXT NOT NULL, email TEXT NOT NULL UNIQUE, password_hash CHAR(60) NOT NULL, valid_email BOOLEAN CHECK (valid_email IN (0, 1)) DEFAULT 0, confirmation_code TEXT , reset_password_code TEXT ,is_admin BOOLEAN CHECK (is_admin IN (0, 1)) DEFAULT 0, organisation TEXT NOT NULL, country TEXT NOT NULL, user_planned_usage TEXT NOT NULL, user_creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, deleted TIMESTAMP DEFAULT NULL);"
this.db.run(sql_create, [])

// Create admin user if not exist
const sql_admin = "INSERT OR IGNORE INTO user (first_name, last_name, email, password_hash, valid_email, is_admin, organisation, country, user_planned_usage) VALUES ('admin', 'admin', '[email protected]', 'admin', 1, 1, 'admin', 'admin', 'admin');"
this.db.run(sql_admin, [])
}

async create(user: UserRequesCreationtModel): Promise<number> {
Expand Down
1 change: 0 additions & 1 deletion src/domain/repositories/user-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export class UserRepositoryImpl implements UserRepository {
// Deleted : current date time
deleted: new Date().toISOString()
}
console.log(anonymized_user)

const nb_of_updated_user = await this.updateUser(anonymized_user, params)
return nb_of_updated_user
Expand Down
1 change: 0 additions & 1 deletion src/infra/mailer/nodemailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class NodemailerAdapter implements MailerWrapper {//implements sendeamils
}

async send_reset_password_email(transporter: nodemailer.Transporter, user: UserResponseModel, resetPasswordToken: string): Promise<void> {
console.log(user)
// Read the HTML file
let htmlContent = "error"
try {
Expand Down

0 comments on commit f3f7115

Please sign in to comment.