mirror of
https://github.com/h44z/wg-portal
synced 2025-02-26 05:49:14 +00:00
migrate old database format correctly, fix typo, update readme
This commit is contained in:
parent
9bd80dbd33
commit
2b77148b81
@ -3,6 +3,7 @@
|
||||
[](https://travis-ci.com/h44z/wg-portal)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||

|
||||
[](https://goreportcard.com/report/github.com/h44z/wg-portal)
|
||||

|
||||

|
||||
[](https://hub.docker.com/r/h44z/wg-portal/)
|
||||
@ -27,6 +28,7 @@ It also supports LDAP (Active Directory or OpenLDAP) as authentication provider.
|
||||
* Dockerized
|
||||
* Responsive template
|
||||
* One single binary
|
||||
* Can be used with existing WireGuard setups
|
||||
|
||||

|
||||
|
||||
|
@ -59,7 +59,7 @@ func (provider Provider) Login(ctx *authentication.AuthContext) (string, error)
|
||||
return "", errors.New("empty username or password")
|
||||
}
|
||||
|
||||
// Authenticate agains the users database
|
||||
// Authenticate against the users database
|
||||
user := users.User{}
|
||||
provider.db.Where("email = ?", username).First(&user)
|
||||
|
||||
|
@ -75,6 +75,15 @@ func NewManager(cfg *Config) (*Manager, error) {
|
||||
return nil, errors.Wrapf(err, "failed to setup user database %s", cfg.Database)
|
||||
}
|
||||
|
||||
// check if old user table exists (from version <= 1.0.2), if so rename it to peers.
|
||||
if m.db.Migrator().HasTable("users") && !m.db.Migrator().HasTable("peers") {
|
||||
if err := m.db.Migrator().RenameTable("users", "peers"); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to migrate old database structure")
|
||||
} else {
|
||||
logrus.Infof("upgraded database format from version v1.0.2")
|
||||
}
|
||||
}
|
||||
|
||||
return m, m.MigrateUserDB()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user