Remove misc files, add root permission, and update env template

This commit is contained in:
garrettmills
2020-07-07 19:30:48 -05:00
parent 6bd1ddc064
commit 60533848a1
5 changed files with 37 additions and 11 deletions

View File

@@ -76,7 +76,20 @@ class AuthController extends Controller {
trap: 'password_reset', // Force user to reset password
})
user.promote('base_user')
const Setting = this.models.get('Setting')
try {
const default_roles = await Setting.get('auth.default_roles')
if ( Array.isArray(default_roles) ) {
for ( const role of default_roles ) user.promote(role)
}
} catch (e) {
this.output.error('Unable to read default roles to promote registered user: ')
this.output.error(e)
}
// If this is the first user, make them root
if ( !(await User.findOne()) ) user.promote('root')
await user.save()
// Log in the user automatically