mirror of https://github.com/gophish/gophish
Fixed the way the initial admin is created to better support MySQL installations. Fixes #948
parent
8d37bb1b39
commit
0f4ac70049
|
@ -82,10 +82,6 @@ func chooseDBDriver(name, openStr string) goose.DBDriver {
|
||||||
// Setup initializes the Conn object
|
// Setup initializes the Conn object
|
||||||
// It also populates the Gophish Config object
|
// It also populates the Gophish Config object
|
||||||
func Setup() error {
|
func Setup() error {
|
||||||
create_db := false
|
|
||||||
if _, err = os.Stat(config.Conf.DBPath); err != nil || config.Conf.DBPath == ":memory:" {
|
|
||||||
create_db = true
|
|
||||||
}
|
|
||||||
// Setup the goose configuration
|
// Setup the goose configuration
|
||||||
migrateConf := &goose.DBConf{
|
migrateConf := &goose.DBConf{
|
||||||
MigrationsDir: config.Conf.MigrationsPath,
|
MigrationsDir: config.Conf.MigrationsPath,
|
||||||
|
@ -113,9 +109,10 @@ func Setup() error {
|
||||||
Logger.Println(err)
|
Logger.Println(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
//If the database didn't exist, we need to create the admin user
|
// Create the admin user if it doesn't exist
|
||||||
if create_db {
|
var userCount int64
|
||||||
//Create the default user
|
db.Model(&User{}).Count(&userCount)
|
||||||
|
if userCount == 0 {
|
||||||
initUser := User{
|
initUser := User{
|
||||||
Username: "admin",
|
Username: "admin",
|
||||||
Hash: "$2a$10$IYkPp0.QsM81lYYPrQx6W.U6oQGw7wMpozrKhKAHUBVL4mkm/EvAS", //gophish
|
Hash: "$2a$10$IYkPp0.QsM81lYYPrQx6W.U6oQGw7wMpozrKhKAHUBVL4mkm/EvAS", //gophish
|
||||||
|
|
Loading…
Reference in New Issue