Commit 17e397b4 authored by Richer Maximilien's avatar Richer Maximilien

[p] Platform handler

parent 45cd0c5c
Pipeline #2190 passed with stage
......@@ -43,8 +43,7 @@ func (s *platformServer) Auth(ctx context.Context, in *api.AuthRequest) (*api.Re
//
// Handle incoming UnregisterRequest messages
func (s *platformServer) Unregister(ctx context.Context, in *api.Empty) (*api.ErrorCode, error) {
// TODO
return nil, nil
return user.Unregister(s.DB, net.GetClientHash(&ctx)), nil
}
// PostContract handler
......
package user
import (
api "dfss/dfssp/api"
"dfss/mgdb"
"gopkg.in/mgo.v2/bson"
)
// Unregister delete a user based on the provided certificate hash
func Unregister(manager *mgdb.MongoManager, userCertificateHash []byte) *api.ErrorCode {
count, err := manager.Get("users").DeleteAll(bson.M{
"certHash": bson.M{"$eq": userCertificateHash},
})
if err != nil || count == 0 {
return &api.ErrorCode{Code: api.ErrorCode_INVARG, Message: "No user matching provided certificate"}
}
return &api.ErrorCode{Code: api.ErrorCode_SUCCESS}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment