aboutsummaryrefslogtreecommitdiff
path: root/profile.go
diff options
context:
space:
mode:
Diffstat (limited to 'profile.go')
-rw-r--r--profile.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/profile.go b/profile.go
index a082ad8..58e7d96 100644
--- a/profile.go
+++ b/profile.go
@@ -8,7 +8,7 @@ import (
)
type ProfileTplData struct {
- Status *LoginStatus
+ User *LoggedUser
ErrorMessage string
Success bool
Mail string
@@ -23,24 +23,24 @@ type ProfileTplData struct {
func handleProfile(w http.ResponseWriter, r *http.Request) {
templateProfile := getTemplate("profile.html")
- login := checkLogin(w, r)
- if login == nil {
+ user := RequireUserHtml(w, r)
+ if user == nil {
return
}
data := &ProfileTplData{
- Status: login,
+ User: user,
ErrorMessage: "",
Success: false,
}
- data.Mail = login.UserEntry.GetAttributeValue("mail")
- data.DisplayName = login.UserEntry.GetAttributeValue("displayname")
- data.GivenName = login.UserEntry.GetAttributeValue("givenname")
- data.Surname = login.UserEntry.GetAttributeValue("sn")
- data.Visibility = login.UserEntry.GetAttributeValue(FIELD_NAME_DIRECTORY_VISIBILITY)
- data.Description = login.UserEntry.GetAttributeValue("description")
- data.ProfilePicture = login.UserEntry.GetAttributeValue(FIELD_NAME_PROFILE_PICTURE)
+ data.Mail = user.Entry.GetAttributeValue("mail")
+ data.DisplayName = user.Entry.GetAttributeValue("displayname")
+ data.GivenName = user.Entry.GetAttributeValue("givenname")
+ data.Surname = user.Entry.GetAttributeValue("sn")
+ data.Visibility = user.Entry.GetAttributeValue(FIELD_NAME_DIRECTORY_VISIBILITY)
+ data.Description = user.Entry.GetAttributeValue("description")
+ data.ProfilePicture = user.Entry.GetAttributeValue(FIELD_NAME_PROFILE_PICTURE)
if r.Method == "POST" {
//5MB maximum size files
@@ -56,7 +56,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
}
data.Visibility = visible
- profilePicture, err := uploadProfilePicture(w, r, login)
+ profilePicture, err := uploadProfilePicture(w, r, user)
if err != nil {
data.ErrorMessage = err.Error()
}
@@ -65,7 +65,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
data.ProfilePicture = profilePicture
}
- modify_request := ldap.NewModifyRequest(login.Info.DN, nil)
+ modify_request := ldap.NewModifyRequest(user.Login.Info.DN(), nil)
modify_request.Replace("displayname", []string{data.DisplayName})
modify_request.Replace("givenname", []string{data.GivenName})
modify_request.Replace("sn", []string{data.Surname})
@@ -75,7 +75,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
modify_request.Replace(FIELD_NAME_PROFILE_PICTURE, []string{data.ProfilePicture})
}
- err = login.conn.Modify(modify_request)
+ err = user.Login.conn.Modify(modify_request)
if err != nil {
data.ErrorMessage = err.Error()
} else {
@@ -88,7 +88,7 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
}
type PasswdTplData struct {
- Status *LoginStatus
+ User *LoggedUser
ErrorMessage string
TooShortError bool
NoMatchError bool
@@ -98,13 +98,13 @@ type PasswdTplData struct {
func handlePasswd(w http.ResponseWriter, r *http.Request) {
templatePasswd := getTemplate("passwd.html")
- login := checkLogin(w, r)
- if login == nil {
+ user := RequireUserHtml(w, r)
+ if user == nil {
return
}
data := &PasswdTplData{
- Status: login,
+ User: user,
ErrorMessage: "",
Success: false,
}
@@ -120,11 +120,11 @@ func handlePasswd(w http.ResponseWriter, r *http.Request) {
} else if password2 != password {
data.NoMatchError = true
} else {
- modify_request := ldap.NewModifyRequest(login.Info.DN, nil)
+ modify_request := ldap.NewModifyRequest(user.Login.Info.DN(), nil)
pw, err := SSHAEncode(password)
if err == nil {
modify_request.Replace("userpassword", []string{pw})
- err := login.conn.Modify(modify_request)
+ err := user.Login.conn.Modify(modify_request)
if err != nil {
data.ErrorMessage = err.Error()
} else {