[이민권] 계정 삭제
- 계정 삭제 취소 기능 추가
This commit is contained in:
@ -673,18 +673,27 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
|||||||
link, err := sh.mongoClient.FindOneAndUpdate(CollectionLink, bson.M{
|
link, err := sh.mongoClient.FindOneAndUpdate(CollectionLink, bson.M{
|
||||||
"platform": authtype,
|
"platform": authtype,
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
"_ts": bson.M{"$exists": false},
|
|
||||||
}, bson.M{
|
}, bson.M{
|
||||||
"$setOnInsert": bson.M{
|
"$setOnInsert": bson.M{
|
||||||
"create": createtime,
|
"create": createtime,
|
||||||
"email": email,
|
"email": email,
|
||||||
},
|
},
|
||||||
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{"_id": 1}))
|
}, options.FindOneAndUpdate().SetReturnDocument(options.After).SetUpsert(true).SetProjection(bson.M{
|
||||||
|
"_id": 1,
|
||||||
|
"_ts": 1,
|
||||||
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("authorize failed :", err)
|
logger.Error("authorize failed :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
delts := link["_ts"].(primitive.Timestamp)
|
||||||
|
if !delts.IsZero() {
|
||||||
|
// 삭제된 계정. 삭제 되었다고 알려주자
|
||||||
|
w.Header().Add("MG-ACCOUNT-DELETED", "TRUE")
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
linkid := link["_id"].(primitive.ObjectID)
|
linkid := link["_id"].(primitive.ObjectID)
|
||||||
newaccid := primitive.NewObjectID()
|
newaccid := primitive.NewObjectID()
|
||||||
@ -825,6 +834,7 @@ func (sh *serviceDescription) delacc(w http.ResponseWriter, r *http.Request) {
|
|||||||
sType := queryvals.Get("stype")
|
sType := queryvals.Get("stype")
|
||||||
sId := queryvals.Get("sid")
|
sId := queryvals.Get("sid")
|
||||||
sk := queryvals.Get("sk")
|
sk := queryvals.Get("sk")
|
||||||
|
cancel := queryvals.Has("cancel")
|
||||||
|
|
||||||
authInfo := sh.auths.Find(sk)
|
authInfo := sh.auths.Find(sk)
|
||||||
if authInfo == nil {
|
if authInfo == nil {
|
||||||
@ -857,20 +867,25 @@ func (sh *serviceDescription) delacc(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delfilter := primitive.M{"_id": bson.M{"$in": addIdFilter}}
|
delfilter := primitive.M{"_id": bson.M{"$in": addIdFilter}}
|
||||||
curtime := primitive.NewDateTimeFromTime(time.Now().UTC())
|
var delop primitive.M
|
||||||
updated, _, err := sh.mongoClient.Update(CollectionAccount, delfilter, bson.M{
|
if !cancel {
|
||||||
"$set": bson.M{"_ts": curtime},
|
curtime := primitive.NewDateTimeFromTime(time.Now().UTC())
|
||||||
}, options.Update().SetUpsert(false))
|
delop = primitive.M{
|
||||||
|
"$set": primitive.M{"_ts": curtime},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delop = primitive.M{
|
||||||
|
"$unset": primitive.M{"_ts": true},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updated, _, err := sh.mongoClient.Update(CollectionAccount, delfilter, delop, options.Update().SetUpsert(false))
|
||||||
if !updated || err != nil {
|
if !updated || err != nil {
|
||||||
logger.Error("delacc failed. Update CollectionAccount timestamp err :", err)
|
logger.Error("delacc failed. Update CollectionAccount timestamp err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
updated, _, err = sh.mongoClient.Update(CollectionLink, delfilter, bson.M{
|
updated, _, err = sh.mongoClient.Update(CollectionLink, delfilter, delop, options.Update().SetUpsert(false))
|
||||||
"$set": bson.M{"_ts": curtime},
|
|
||||||
}, options.Update().SetUpsert(false))
|
|
||||||
if !updated || err != nil {
|
if !updated || err != nil {
|
||||||
logger.Error("delacc failed. Update CollectionLink timestamp err :", err)
|
logger.Error("delacc failed. Update CollectionLink timestamp err :", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
|||||||
Reference in New Issue
Block a user