mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-02 10:57:57 +00:00
e.globalUserDelete function is using email as parameter now
This commit is contained in:
@@ -54,7 +54,7 @@ func (e mainEnv) uiConfigurationDump(w http.ResponseWriter, r *http.Request, ps
|
|||||||
w.Write([]byte(finalJSON))
|
w.Write([]byte(finalJSON))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e mainEnv) globalUserDelete(userTOKEN string) {
|
func (e mainEnv) globalUserDelete(email string) {
|
||||||
// not implemented
|
// not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ func (e mainEnv) expUsers() error {
|
|||||||
records, err := e.db.store.GetExpiring(storage.TblName.Users, "expstatus", "wait")
|
records, err := e.db.store.GetExpiring(storage.TblName.Users, "expstatus", "wait")
|
||||||
for _, rec := range records {
|
for _, rec := range records {
|
||||||
userTOKEN := rec["token"].(string)
|
userTOKEN := rec["token"].(string)
|
||||||
resultJSON, _ := e.db.getUserJson(userTOKEN)
|
resultJSON, userBSON, _ := e.db.getUser(userTOKEN)
|
||||||
if resultJSON != nil {
|
if resultJSON != nil {
|
||||||
e.globalUserDelete(userTOKEN)
|
email := getStringValue(userBSON["email"])
|
||||||
|
if len(email) > 0 {
|
||||||
|
e.globalUserDelete(email)
|
||||||
|
}
|
||||||
e.db.deleteUserRecord(resultJSON, userTOKEN)
|
e.db.deleteUserRecord(resultJSON, userTOKEN)
|
||||||
e.db.updateUserExpStatus(userTOKEN, "expired")
|
e.db.updateUserExpStatus(userTOKEN, "expired")
|
||||||
}
|
}
|
||||||
@@ -135,14 +138,17 @@ func (e mainEnv) expDeleteData(w http.ResponseWriter, r *http.Request, ps httpro
|
|||||||
if enforceUUID(w, identity, event) == false {
|
if enforceUUID(w, identity, event) == false {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resultJSON, userTOKEN, err := e.db.getUserJsonByIndex(identity, mode, e.conf)
|
userJSON, userTOKEN, userBSON, err := e.db.getUserByIndex(identity, mode, e.conf)
|
||||||
if resultJSON == nil || err != nil {
|
if userJSON == nil || err != nil {
|
||||||
returnError(w, r, "internal error", 405, nil, event)
|
returnError(w, r, "internal error", 405, nil, event)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
event.Record = userTOKEN
|
event.Record = userTOKEN
|
||||||
e.globalUserDelete(userTOKEN)
|
email := getStringValue(userBSON["email"])
|
||||||
_, err = e.db.deleteUserRecord(resultJSON, userTOKEN)
|
if len(email) > 0 {
|
||||||
|
e.globalUserDelete(email)
|
||||||
|
}
|
||||||
|
_, err = e.db.deleteUserRecord(userJSON, userTOKEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnError(w, r, "internal error", 405, nil, event)
|
returnError(w, r, "internal error", 405, nil, event)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -251,15 +251,16 @@ func (e mainEnv) userDelete(w http.ResponseWriter, r *http.Request, ps httproute
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
var resultJSON []byte
|
var userBSON bson.M
|
||||||
|
var userJSON []byte
|
||||||
userTOKEN := identity
|
userTOKEN := identity
|
||||||
if mode == "token" {
|
if mode == "token" {
|
||||||
if enforceUUID(w, identity, event) == false {
|
if enforceUUID(w, identity, event) == false {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resultJSON, err = e.db.getUserJson(identity)
|
userJSON, userBSON, err = e.db.getUser(identity)
|
||||||
} else {
|
} else {
|
||||||
resultJSON, userTOKEN, err = e.db.getUserJsonByIndex(identity, mode, e.conf)
|
userJSON, userTOKEN, userBSON, err = e.db.getUserByIndex(identity, mode, e.conf)
|
||||||
event.Record = userTOKEN
|
event.Record = userTOKEN
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -270,7 +271,13 @@ func (e mainEnv) userDelete(w http.ResponseWriter, r *http.Request, ps httproute
|
|||||||
if authResult == "" {
|
if authResult == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if resultJSON == nil {
|
if userJSON == nil {
|
||||||
|
if authResult == "root" && mode == "email" {
|
||||||
|
e.globalUserDelete(identity)
|
||||||
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
w.WriteHeader(200)
|
||||||
|
fmt.Fprintf(w, `{"status":"ok","result":"done"}`)
|
||||||
|
}
|
||||||
returnError(w, r, "record not found", 405, nil, event)
|
returnError(w, r, "record not found", 405, nil, event)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -289,9 +296,12 @@ func (e mainEnv) userDelete(w http.ResponseWriter, r *http.Request, ps httproute
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e.globalUserDelete(userTOKEN)
|
email := getStringValue(userBSON["email"])
|
||||||
|
if len(email) > 0 {
|
||||||
|
e.globalUserDelete(email)
|
||||||
|
}
|
||||||
//fmt.Printf("deleting user %s\n", userTOKEN)
|
//fmt.Printf("deleting user %s\n", userTOKEN)
|
||||||
_, err = e.db.deleteUserRecord(resultJSON, userTOKEN)
|
_, err = e.db.deleteUserRecord(userJSON, userTOKEN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnError(w, r, "internal error", 405, err, event)
|
returnError(w, r, "internal error", 405, err, event)
|
||||||
return
|
return
|
||||||
@@ -300,7 +310,7 @@ func (e mainEnv) userDelete(w http.ResponseWriter, r *http.Request, ps httproute
|
|||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
fmt.Fprintf(w, `{"status":"ok","result":"done"}`)
|
fmt.Fprintf(w, `{"status":"ok","result":"done"}`)
|
||||||
notifyURL := e.conf.Notification.NotificationURL
|
notifyURL := e.conf.Notification.NotificationURL
|
||||||
notifyForgetMe(notifyURL, resultJSON, "token", userTOKEN)
|
notifyForgetMe(notifyURL, userJSON, "token", userTOKEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e mainEnv) userPrelogin(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
func (e mainEnv) userPrelogin(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
|||||||
Reference in New Issue
Block a user