Skip to content

Commit

Permalink
Merge pull request #291 from linkernetworks/johnlin/rename
Browse files Browse the repository at this point in the history
[Hot-fix] rename
  • Loading branch information
John-Lin authored Aug 28, 2018
2 parents 50b64eb + 789ec54 commit abca5d8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/server/handler_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func createNetworkHandler(ctx *web.Context) {
sp, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response
mgoID, ok := req.Attribute("UserID").(string)
userID, ok := req.Attribute("UserID").(string)
if !ok {
response.Unauthorized(req.Request, resp.ResponseWriter, fmt.Errorf("Unauthorized: User ID is empty"))
return
Expand Down Expand Up @@ -62,7 +62,7 @@ func createNetworkHandler(ctx *web.Context) {

network.ID = bson.NewObjectId()
network.CreatedAt = timeutils.Now()
network.OwnerID = bson.ObjectIdHex(mgoID)
network.OwnerID = bson.ObjectIdHex(userID)
if err := session.Insert(entity.NetworkCollectionName, &network); err != nil {
if mgo.IsDup(err) {
response.Conflict(req.Request, resp, fmt.Errorf("Network Name: %s already existed", network.Name))
Expand Down
4 changes: 2 additions & 2 deletions src/server/handler_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func createPodHandler(ctx *web.Context) {
sp, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response
mgoID, ok := req.Attribute("UserID").(string)
userID, ok := req.Attribute("UserID").(string)
if !ok {
response.Unauthorized(req.Request, resp.ResponseWriter, fmt.Errorf("Unauthorized: User ID is empty"))
return
Expand Down Expand Up @@ -62,7 +62,7 @@ func createPodHandler(ctx *web.Context) {
return
}

p.OwnerID = bson.ObjectIdHex(mgoID)
p.OwnerID = bson.ObjectIdHex(userID)
if err := session.Insert(entity.PodCollectionName, &p); err != nil {
if mgo.IsDup(err) {
response.Conflict(req.Request, resp.ResponseWriter, fmt.Errorf("Pod Name: %s already existed", p.Name))
Expand Down
4 changes: 2 additions & 2 deletions src/server/handler_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func createServiceHandler(ctx *web.Context) {
sp, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response
mgoID, ok := req.Attribute("UserID").(string)
userID, ok := req.Attribute("UserID").(string)
if !ok {
response.Unauthorized(req.Request, resp.ResponseWriter, fmt.Errorf("Unauthorized: User ID is empty"))
return
Expand All @@ -48,7 +48,7 @@ func createServiceHandler(ctx *web.Context) {
// Check whether this name has been used
s.ID = bson.NewObjectId()
s.CreatedAt = timeutils.Now()
s.OwnerID = bson.ObjectIdHex(mgoID)
s.OwnerID = bson.ObjectIdHex(userID)
if err := service.CreateService(sp, &s); err != nil {
if errors.IsAlreadyExists(err) {
response.Conflict(req.Request, resp.ResponseWriter, fmt.Errorf("Service Name: %s already existed", s.Name))
Expand Down
4 changes: 2 additions & 2 deletions src/server/handler_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ func signUpUserHandler(ctx *web.Context) {

func verifyTokenHandler(ctx *web.Context) {
_, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response
mgoID, ok := req.Attribute("UserID").(string)
userID, ok := req.Attribute("UserID").(string)
if !ok {
response.Unauthorized(req.Request, resp.ResponseWriter, fmt.Errorf("Unauthorized: User ID is empty"))
return
}
http.Redirect(resp.ResponseWriter, req.Request, "/v1/users/"+mgoID, 303)
http.Redirect(resp.ResponseWriter, req.Request, "/v1/users/"+userID, 303)
}

func signInUserHandler(ctx *web.Context) {
Expand Down
4 changes: 2 additions & 2 deletions src/server/handler_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

func createVolumeHandler(ctx *web.Context) {
sp, req, resp := ctx.ServiceProvider, ctx.Request, ctx.Response
mgoID, ok := req.Attribute("UserID").(string)
userID, ok := req.Attribute("UserID").(string)
if !ok {
response.Unauthorized(req.Request, resp.ResponseWriter, fmt.Errorf("Unauthorized: User ID is empty"))
return
Expand All @@ -48,7 +48,7 @@ func createVolumeHandler(ctx *web.Context) {
// Check whether this name has been used
v.ID = bson.NewObjectId()
v.CreatedAt = timeutils.Now()
v.OwnerID = bson.ObjectIdHex(mgoID)
v.OwnerID = bson.ObjectIdHex(userID)
// Generate the metaName for PVC meta name and we will use it future
if err := volume.CreateVolume(sp, &v); err != nil {
if errors.IsAlreadyExists(err) {
Expand Down

0 comments on commit abca5d8

Please sign in to comment.