Skip to content

Commit

Permalink
added capaility to update passwords for user accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Piyush Harsh committed Nov 15, 2016
1 parent 2790d9a commit ccb71ef
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions usermgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,22 @@ func UserUpdateHandler(out http.ResponseWriter, in *http.Request) {
MyFileInfo.Println("Received malformed request on URI:/admin/user/{id} PUT for uid:", id)
} else {
status := 0
if len(u.CapabilityList) == 0 {
//update just the admin-flag
status = UpdateUser(dbArg, "user", "isadmin", u.AdminFlag, id)
} else if len(u.AdminFlag) == 0 {
//update just the capability list
status = UpdateUser(dbArg, "user", "capability", u.CapabilityList, id)
} else {
//update both the fields
if len(u.AdminFlag) != 0 {
//update the admin-flag
status = UpdateUser(dbArg, "user", "isadmin", u.AdminFlag, id)
}
if len(u.CapabilityList) != 0 {
//update the capability list
status = UpdateUser(dbArg, "user", "capability", u.CapabilityList, id)
}
if len(u.Password) != 0 {
//update the Password
data := []byte(u.Password)
hash := sha1.Sum(data)
sha1hash := hex.EncodeToString(hash[:])
MyFileInfo.Println("SHA-1 Hash Generated for the new password:", sha1hash)
status = UpdateUser(dbArg, "user", "password", sha1hash, id)
}
var jsonbody = ""
if status == 1 {
jsonbody = staticMsgs[16]
Expand Down

0 comments on commit ccb71ef

Please sign in to comment.