Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Add authSource to database config.
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTalmadge committed Jul 4, 2020
1 parent aa714aa commit adb1939
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"name": "studybot",
"auth": true,
"username": "admin",
"password": "foobar"
"password": "foobar",
"authSource": "admin"
},

"web": {
Expand Down
1 change: 1 addition & 0 deletions src/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface DatabaseConfig {
auth: boolean;
username?: string;
password?: string;
authSource?: string;
}

export interface WebConfig {
Expand Down
3 changes: 3 additions & 0 deletions src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export class ConfigService {
if(!this.config.database.password) {
throw Error("Database auth is enabled but password is missing or empty.");
}
if(!this.config.database.authSource) {
throw Error("Database auth is enabled but authSource is missing or empty.");
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/services/database/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export class DatabaseService {
this.mongooseInstance = await mongoose.connect(`mongodb://${dbConfig.address}/${dbConfig.name}`, {
useNewUrlParser: true,
useUnifiedTopology: true,
auth
auth,
authSource: dbConfig.authSource
});
}

Expand Down

0 comments on commit adb1939

Please sign in to comment.