Skip to content

Commit

Permalink
Merge pull request #121 from esimonov/fix_user_by_federated_id
Browse files Browse the repository at this point in the history
Fix UserByFederatedID
  • Loading branch information
esimonov authored Jun 1, 2020
2 parents 5211fbd + dba3b68 commit 86bcf65
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM golang:1.14.1 as builder
WORKDIR $GOPATH/src/github.com/madappgang/identifo
COPY . ./
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /app .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /identifo .

FROM alpine:latest
RUN apk --no-cache add ca-certificates
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DOCKER_IMAGE_VERSION = 1.0.0


docker_image:
docker build --tag madappgangd/identifo:latest --tag madappgangd/identifo:$(DOCKER_IMAGE_VERSION) .


publish: docker_image
docker push madappgangd/identifo:latest
docker push madappgangd/identifo:$(DOCKER_IMAGE_VERSION)
2 changes: 1 addition & 1 deletion storage/mongo/app_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (as *AppStorage) addNewApp(app model.AppData) (model.AppData, error) {
return nil, model.ErrorWrongDataFormat
}

if _, err := primitive.ObjectIDFromHex(app.ID()); err != nil {
if objID, err := primitive.ObjectIDFromHex(app.ID()); err != nil || objID == primitive.NilObjectID {
a.appData.ID = primitive.NewObjectID()
}

Expand Down
2 changes: 1 addition & 1 deletion storage/mongo/user_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (us *UserStorage) UserByFederatedID(provider model.FederatedIdentityProvide
defer cancel()

var u userData
if err := us.coll.FindOne(ctx, bson.M{"federatedIDs": sid}).Decode(&u); err != nil {
if err := us.coll.FindOne(ctx, bson.M{"federated_ids": sid}).Decode(&u); err != nil {
return nil, model.ErrUserNotFound
}
//clear password hash
Expand Down

0 comments on commit 86bcf65

Please sign in to comment.