mirror of
https://github.com/DJSundog/wg-portal.git
synced 2024-11-23 07:03:50 -05:00
migrate old database format correctly, fix typo, update readme
This commit is contained in:
parent
9bd80dbd33
commit
2b77148b81
@ -3,6 +3,7 @@
|
||||
[![Build Status](https://travis-ci.com/h44z/wg-portal.svg?token=q4pSqaqT58Jzpxdx62xk&branch=master)](https://travis-ci.com/h44z/wg-portal)
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
|
||||
![GitHub last commit](https://img.shields.io/github/last-commit/h44z/wg-portal)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/h44z/wg-portal)](https://goreportcard.com/report/github.com/h44z/wg-portal)
|
||||
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/h44z/wg-portal)
|
||||
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/h44z/wg-portal)
|
||||
[![Docker Pulls](https://img.shields.io/docker/pulls/h44z/wg-portal.svg)](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
|
||||
|
||||
![Screenshot](screenshot.png)
|
||||
|
||||
|
@ -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