fix: automatic root admin creation if heroku

This commit is contained in:
NGPixel 2017-05-15 22:00:01 -04:00
parent b32a427abc
commit de23e6c498
4 changed files with 39 additions and 17 deletions

View File

@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [Unreleased]
### Added ### Added
- **Deploy**: Heroku support
- **History**: History section to list all changes - **History**: History section to list all changes
- **Localization**: All UI text elements are now localized - **Localization**: All UI text elements are now localized
- **Localization**: Chinese locale is now available (thanks to @choicky) - **Localization**: Chinese locale is now available (thanks to @choicky)

View File

@ -44,24 +44,20 @@ Wiki.js can run on virtually all platforms where Node.js can (Windows, Mac, Linu
## Milestones ## Milestones
Current and upcoming milestones *(features only, see the [changelog](https://github.com/Requarks/wiki/blob/master/CHANGELOG.md) for list of bug fixes)*: Current and upcoming milestones *(major features only, see the [changelog](https://github.com/Requarks/wiki/blob/master/CHANGELOG.md) for complete list of features and bug fixes)*:
### Beta 11
- [x] Azure AD authentication
- [x] MathML / Tex math equations
- [x] Support for CJK (Chinese, Japanese & Korean) characters in content, meta and uploads
- [x] All Pages section
### Beta 12 ### Beta 12
- [ ] Better localization in the UI - [ ] Better localization in the UI
- [ ] History / Revert to previous version feature - [x] Heroku support
- [ ] Docker support + Auto compile/publish to Docker Hub
- [ ] Heroku support
### Beta 13 ### Beta 13
- [ ] History / Revert to previous version feature
- [ ] Docker support + Auto compile/publish to Docker Hub
### Beta 14
- [ ] Insert Link modal in Editor - [ ] Insert Link modal in Editor
- [ ] Better simultaneous user editing handling - [ ] Better simultaneous user editing handling
- [ ] Preview changes directly from the editor, without saving - [ ] Preview changes directly from the editor, without saving
@ -83,8 +79,9 @@ We are looking for translators to make Wiki.js available in multiple languages.
**Languages that are already translated:** **Languages that are already translated:**
- [x] English - [x] English
- [x] French
- [x] Chinese - *Thanks to [@choicky](https://github.com/choicky)* - [x] Chinese - *Thanks to [@choicky](https://github.com/choicky)*
- [x] French
- [x] Korean - *Thanks to [@junwonpk](https://github.com/junwonpk)*
- [x] Russian - *Thanks to [@efimlosev](https://github.com/efimlosev)* - [x] Russian - *Thanks to [@efimlosev](https://github.com/efimlosev)*
- [x] Spanish - *Thanks to [@MatiasArriola](https://github.com/MatiasArriola)* - [x] Spanish - *Thanks to [@MatiasArriola](https://github.com/MatiasArriola)*

View File

@ -57,11 +57,11 @@ auth:
local: local:
enabled: true enabled: true
google: google:
enabled: true enabled: false
clientId: GOOGLE_CLIENT_ID clientId: GOOGLE_CLIENT_ID
clientSecret: GOOGLE_CLIENT_SECRET clientSecret: GOOGLE_CLIENT_SECRET
microsoft: microsoft:
enabled: true enabled: false
clientId: MS_APP_ID clientId: MS_APP_ID
clientSecret: MS_APP_SECRET clientSecret: MS_APP_SECRET
facebook: facebook:

View File

@ -216,7 +216,7 @@ module.exports = function (passport) {
// Create users for first-time // Create users for first-time
db.onReady.then(() => { db.onReady.then(() => {
db.User.findOne({ provider: 'local', email: 'guest' }).then((c) => { return db.User.findOne({ provider: 'local', email: 'guest' }).then((c) => {
if (c < 1) { if (c < 1) {
// Create guest account // Create guest account
@ -238,8 +238,32 @@ module.exports = function (passport) {
winston.error(err) winston.error(err)
}) })
} }
}) }).then(() => {
if (process.env.WIKI_JS_HEROKU) {
return db.User.findOne({ provider: 'local', email: process.env.WIKI_ADMIN_EMAIL }).then((c) => {
if (c < 1) {
// Create root admin account (HEROKU ONLY)
return true return db.User.create({
provider: 'local',
email: process.env.WIKI_ADMIN_EMAIL,
name: 'Administrator',
password: '$2a$04$MAHRw785Xe/Jd5kcKzr3D.VRZDeomFZu2lius4gGpZZ9cJw7B7Mna', // admin123 (default)
rights: [{
role: 'admin',
path: '/',
exact: false,
deny: false
}]
}).then(() => {
winston.info('[AUTH] Root admin account created successfully!')
}).catch((err) => {
winston.error('[AUTH] An error occured while creating root admin account:')
winston.error(err)
})
} else { return true }
})
} else { return true }
})
}) })
} }