work on LDAP
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-04 15:53:21 +11:00
parent d6c082675e
commit 7a8fd8e200
4 changed files with 46 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
package models
import (
"database/sql"
"errors"
"log"
"net/http"
@@ -91,6 +92,18 @@ func LoginCheck(username string, password string) (string, error) {
err = db.QueryRowx("SELECT * FROM Users WHERE Username=?", username).StructScan(&u)
if err != nil {
if err == sql.ErrNoRows {
// check LDAP if enabled
if LdapEnabled {
//check, err := LdapLoginCheck(username, password)
check := VerifyLdapCreds(username, password)
if check {
u.UserId = StoreLdapUser(username)
}
} else {
return "", errors.New("specified user not found in database")
}
}
log.Printf("LoginCheck error retrieving user from database : '%s'\n", err)
return "", err
} else {
@@ -120,6 +133,14 @@ func LoginCheck(username string, password string) (string, error) {
}
// StoreLdapUser creates a user record in the database and returns the corresponding userId
func StoreLdapUser(username string) int {
// TODO
return 99
}
func GetUserByID(uid uint) (User, error) {
var u User