Skip to content

Commit

Permalink
fixed deprecated features
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshayman committed Aug 2, 2024
1 parent 1073432 commit 1b76c17
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
1 change: 1 addition & 0 deletions call-profile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
ctx := context.Background()
client, err := utils.InitializeFirestoreClient(ctx)
fmt.Println(client, err)
if err != nil {
return events.APIGatewayProxyResponse{}, err
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
go mod tidy
sam build
sam local start-api --env-vars env.json
sam.cmd build
sam.cmd local start-api --env-vars env.json
2 changes: 1 addition & 1 deletion template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Resources:
UtilitiesLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: UtilitiesLayer
LayerName: utilities
Description: Utility functions for identity service
ContentUri: layer/
CompatibleRuntimes:
Expand Down
30 changes: 13 additions & 17 deletions verify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"errors"
"fmt"
"identity-service/layer/utils"
"io/ioutil"
"io"
"math/rand"
"net/http"
"time"
Expand All @@ -29,18 +29,6 @@ type deps struct {
ctx context.Context
}

/*
Function to generate random string
*/
func randSalt(n int) string {
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789")
b := make([]rune, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}

/*
Controller
*/
Expand All @@ -62,7 +50,7 @@ func verify(profileURL string, chaincode string, salt string) (string, error) {
return "BLOCKED", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "BLOCKED", err
}
Expand Down Expand Up @@ -99,12 +87,20 @@ func (d *deps) handler(request events.APIGatewayProxyRequest) (events.APIGateway

if profileStatus == "VERIFIED" {
return events.APIGatewayProxyResponse{
Body: "Already Verified",
Body: "Already Verified",
StatusCode: 409,
}, nil
}

rand.Seed(time.Now().UnixNano())
var salt string = randSalt(21)
source := rand.NewSource(time.Now().UnixNano())
rng := rand.New(source)

var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789")
b := make([]rune, 21)
for i := range b {
b[i] = letters[rng.Intn(len(letters))]
}
var salt string = string(b)

status, err := verify(profileURL, chaincode, salt)
if err != nil {
Expand Down

0 comments on commit 1b76c17

Please sign in to comment.