This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user