Implementing Activate User
This commit is contained in:
parent
a95d8e1213
commit
76b39c0236
2 changed files with 50 additions and 43 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
var EMAIL_REGEXP = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
var EMAIL_REGEXP = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||||
|
|
||||||
func checkInviterLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
func checkInviterLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
|
||||||
|
|
||||||
login := checkLogin(w, r)
|
login := checkLogin(w, r)
|
||||||
if login == nil {
|
if login == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
16
login.go
16
login.go
|
@ -209,17 +209,26 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
username := strings.Join(r.Form["username"], "")
|
username := strings.Join(r.Form["username"], "")
|
||||||
password := strings.Join(r.Form["password"], "")
|
password := strings.Join(r.Form["password"], "")
|
||||||
user_dn := fmt.Sprintf("%s=%s,%s", config.UserNameAttr, username, config.UserBaseDN)
|
user_dn := fmt.Sprintf("%s=%s,%s", config.UserNameAttr, username, config.UserBaseDN)
|
||||||
|
|
||||||
if strings.EqualFold(username, config.AdminAccount) {
|
if strings.EqualFold(username, config.AdminAccount) {
|
||||||
user_dn = username
|
user_dn = username
|
||||||
}
|
}
|
||||||
|
return doLogin(w, r, username, user_dn, password)
|
||||||
|
} else {
|
||||||
|
http.Error(w, "Unsupported method", http.StatusBadRequest)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func doLogin(w http.ResponseWriter, r *http.Request, username string, user_dn string, password string) *LoginInfo {
|
||||||
l := ldapOpen(w)
|
l := ldapOpen(w)
|
||||||
if l == nil {
|
if l == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err := l.Bind(user_dn, password)
|
err := l.Bind(user_dn, password)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
|
templateLogin := getTemplate("login.html")
|
||||||
data := &LoginFormData{
|
data := &LoginFormData{
|
||||||
Username: username,
|
Username: username,
|
||||||
}
|
}
|
||||||
|
@ -255,8 +264,5 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: password,
|
Password: password,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
http.Error(w, "Unsupported method", http.StatusBadRequest)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue