1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: add auto-migrations for old md5 password to maintain backwards compatibility

This commit is contained in:
Ferdinand Mütsch
2020-05-25 22:24:29 +02:00
parent 08675bd99f
commit 6c2f0cb1ec
5 changed files with 67 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ package routes
import (
"fmt"
"github.com/gorilla/schema"
"github.com/muety/wakapi/middlewares"
"github.com/muety/wakapi/models"
"github.com/muety/wakapi/services"
"github.com/muety/wakapi/utils"
@@ -76,7 +77,8 @@ func (h *IndexHandler) Login(w http.ResponseWriter, r *http.Request) {
return
}
if !utils.CheckPassword(user, login.Password, h.config.PasswordSalt) {
// TODO: depending on middleware package here is a hack
if !middlewares.CheckAndMigratePassword(user, &login, h.config.PasswordSalt, h.userSrvc) {
respondAlert(w, "invalid credentials", "", "", http.StatusUnauthorized)
return
}